Re:Rust is a hard way to make a web API
by timmattison on Friday January 15, 2021 @08:58PM
(#25799182)
Does the Either type from the vavr library for Java cover this? https://www.baeldung.com/vavr-either
[ Parent
| on HN ]
Re:Rust is a hard way to make a web API
by PhantomBKB on Friday January 15, 2021 @11:24PM
(#25800019)
I wouldn't say no, because it's built with the right spirit in mind. But at the same time, it's different from languages have native support for sum types. Advantage of sum type is that it can be matched exhaustively like an enum, but at the same time it's flexible to contain any data like a data class.
Having a type available in an optional library is not the same thing as having them baked in from the beginning. The absence of sum types warps a language in grotesquely terrible ways, such as Go's err != nil patterns or Java's exception system and visitor patterns.