#enum-variant #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

#62 in Rust patterns

Download history 3606439/week @ 2025-12-28 6668534/week @ 2026-01-04 7432514/week @ 2026-01-11 7537731/week @ 2026-01-18 8007483/week @ 2026-01-25 8414433/week @ 2026-02-01 8943850/week @ 2026-02-08 8244489/week @ 2026-02-15 8416186/week @ 2026-02-22 10566125/week @ 2026-03-01 10463913/week @ 2026-03-08 10080972/week @ 2026-03-15 9652933/week @ 2026-03-22 9934857/week @ 2026-03-29 10003284/week @ 2026-04-05 10879420/week @ 2026-04-12

41,295,903 downloads per month
Used in 69,664 crates (1,337 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

~145KB