#enum-variant #left-and-right #no-std

no-std either

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

33 releases (stable)

1.16.0 May 20, 2026
1.15.0 Mar 5, 2025
1.14.0 Feb 23, 2025
1.13.0 Jun 25, 2024
0.1.3 Sep 25, 2015

#65 in Rust patterns

Download history 8900430/week @ 2026-02-24 10620647/week @ 2026-03-03 10476254/week @ 2026-03-10 9977441/week @ 2026-03-17 9656240/week @ 2026-03-24 9700556/week @ 2026-03-31 10447068/week @ 2026-04-07 10894261/week @ 2026-04-14 11775447/week @ 2026-04-21 12404058/week @ 2026-04-28 13134907/week @ 2026-05-05 14550220/week @ 2026-05-12 14487633/week @ 2026-05-19 15166247/week @ 2026-05-26 15904104/week @ 2026-06-02 13017268/week @ 2026-06-09

60,822,099 downloads per month
Used in 79,503 crates (1,391 directly)

MIT/Apache

68KB
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

~140KB