#data-structures #no-std #right

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

#59 in Rust patterns

Download history 1780792/week @ 2024-12-30 3046806/week @ 2025-01-06 3235155/week @ 2025-01-13 3133637/week @ 2025-01-20 3582721/week @ 2025-01-27 3615978/week @ 2025-02-03 3583328/week @ 2025-02-10 3668722/week @ 2025-02-17 3950692/week @ 2025-02-24 4317811/week @ 2025-03-03 4496007/week @ 2025-03-10 4790127/week @ 2025-03-17 4761173/week @ 2025-03-24 4429350/week @ 2025-03-31 4725881/week @ 2025-04-07 4394864/week @ 2025-04-14

18,636,708 downloads per month
Used in 42,168 crates (1,055 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