Rust's general-purpose Either sum type with Left and Right
open sourceMIT OR Apache-2.0free
either is a Rust crate with the enum Either, a general-purpose sum type with two cases, Left and Right. It has methods like Option's and Result's, implements traits such as Iterator, Read and Write, and includes try_left! and try_right! macros for short-circuiting like the ? operator. It works without the standard library when its default std feature is turned off. Its README says to use Result instead when the two sides mean success and error. Install it from crates.io as either.
Problems it solves
- return one of two different iterator types from a Rust function
- hold a value that can be one of two types in Rust without writing my own enum
- short-circuit on the left or right side of a two-way value in Rust
Features
- Either enum with Left and Right
- Option- and Result-like methods
- Iterator, Read and Write implementations
- try_left! and try_right! macros
- no_std support
