#data-structures #no-std

no-std either

The enum Either with variants Left and Right is a general purpose sum type with two cases

32 releases (stable)

1.15.0 Mar 5, 2025
1.13.0 Jun 25, 2024
1.10.0 Feb 10, 2024
1.9.0 Jul 22, 2023
0.1.3 Sep 25, 2015

#54 in Rust patterns

Download history 3638482/week @ 2025-01-30 3629994/week @ 2025-02-06 3405502/week @ 2025-02-13 4033751/week @ 2025-02-20 4005254/week @ 2025-02-27 4535797/week @ 2025-03-06 4493603/week @ 2025-03-13 5160493/week @ 2025-03-20 4318974/week @ 2025-03-27 4638082/week @ 2025-04-03 4542197/week @ 2025-04-10 4167017/week @ 2025-04-17 4290855/week @ 2025-04-24 4020956/week @ 2025-05-01 4182367/week @ 2025-05-08 3860951/week @ 2025-05-15

17,106,861 downloads per month
Used in 43,368 crates (1,076 directly)

MIT/Apache

61KB
1K SLoC

The enum Either with variants Left and Right is a general purpose sum type with two cases.

Crate features:

  • "std" Enabled by default. Disable to make the library #![no_std].

  • "serde" Disabled by default. Enable to #[derive(Serialize, Deserialize)] for Either


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.

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. For describing success or error, use the regular Result.

Dependencies

~150KB