#data-structure #no-std

no-std either

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

27 releases (stable)

1.10.0 Feb 10, 2024
1.9.0 Jul 22, 2023
1.8.1 Jan 26, 2023
1.8.0 Aug 17, 2022
0.1.3 Sep 25, 2015

#123 in Data structures

Download history 1897910/week @ 2023-11-02 1938902/week @ 2023-11-09 1864783/week @ 2023-11-16 1703081/week @ 2023-11-23 1968842/week @ 2023-11-30 1993431/week @ 2023-12-07 1906901/week @ 2023-12-14 1180516/week @ 2023-12-21 1302722/week @ 2023-12-28 1883150/week @ 2024-01-04 1910920/week @ 2024-01-11 2058465/week @ 2024-01-18 1992303/week @ 2024-01-25 2094267/week @ 2024-02-01 2254586/week @ 2024-02-08 1863865/week @ 2024-02-15

8,566,332 downloads per month
Used in 27,752 crates (722 directly)

MIT/Apache

58KB
1K SLoC

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.


lib.rs:

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

Crate features:

  • "use_std" Enabled by default. Disable to make the library #![no_std].

  • "serde" Disabled by default. Enable to #[derive(Serialize, Deserialize)] for Either

Dependencies

~185KB