#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

#55 in Rust patterns

Download history 1575467/week @ 2024-12-25 2231794/week @ 2025-01-01 3212150/week @ 2025-01-08 3058344/week @ 2025-01-15 3391145/week @ 2025-01-22 3621500/week @ 2025-01-29 3602359/week @ 2025-02-05 3418312/week @ 2025-02-12 3974948/week @ 2025-02-19 3919536/week @ 2025-02-26 4500042/week @ 2025-03-05 4480360/week @ 2025-03-12 5172302/week @ 2025-03-19 4344543/week @ 2025-03-26 4632419/week @ 2025-04-02 4597235/week @ 2025-04-09

19,583,920 downloads per month
Used in 41,992 crates (1,050 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