The enum Either with variants Left and Right is a general purpose sum type with two cases.
558
stars
310
commits
Rust
primary language
Aug 20, 2026
updated
The enum Either with variants Left and Right is a general purpose sum
type with two cases.
Either has methods that are similar to Option and Result, and it also
implements traits like Iterator, Read, and Write.
The crate includes macros try_left!() and try_right!() to use for
short-circuiting logic, similar to how the ? operator is used with Result.
Note that Either is general purpose and unopinionated about the meaning of
Left and Right. For describing success or error, use the regular Result.
Please read the API documentation here, and see RELEASES.md for the version history.
How to use with cargo:
[dependencies]
either = "1"
Dual-licensed to be compatible with the Rust project.
Licensed under the Apache License, Version 2.0 https://www.apache.org/licenses/LICENSE-2.0 or the MIT license https://opensource.org/licenses/MIT, at your option. This file may not be copied, modified, or distributed except according to those terms.
Rust
100.0%
The enum Either with variants Left and Right is a general purpose sum type with two cases.
558
stars
310
commits
Rust
primary language
Aug 20, 2026
updated
The enum Either with variants Left and Right is a general purpose sum
type with two cases.
Either has methods that are similar to Option and Result, and it also
implements traits like Iterator, Read, and Write.
The crate includes macros try_left!() and try_right!() to use for
short-circuiting logic, similar to how the ? operator is used with Result.
Note that Either is general purpose and unopinionated about the meaning of
Left and Right. For describing success or error, use the regular Result.
Please read the API documentation here, and see RELEASES.md for the version history.
How to use with cargo:
[dependencies]
either = "1"
Dual-licensed to be compatible with the Rust project.
Licensed under the Apache License, Version 2.0 https://www.apache.org/licenses/LICENSE-2.0 or the MIT license https://opensource.org/licenses/MIT, at your option. This file may not be copied, modified, or distributed except according to those terms.
Rust
100.0%