#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 1633720/week @ 2024-12-22 1803236/week @ 2024-12-29 3018091/week @ 2025-01-05 3232594/week @ 2025-01-12 3120016/week @ 2025-01-19 3555838/week @ 2025-01-26 3620915/week @ 2025-02-02 3614601/week @ 2025-02-09 3636085/week @ 2025-02-16 3941197/week @ 2025-02-23 4309424/week @ 2025-03-02 4488821/week @ 2025-03-09 4738164/week @ 2025-03-16 4799135/week @ 2025-03-23 4412261/week @ 2025-03-30 4698229/week @ 2025-04-06

18,991,534 downloads per month
Used in 41,881 crates (1,047 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