#data-structure #no-std

no-std either

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

22 releases (14 stable)

Uses old Rust 2015

1.6.1 Sep 16, 2020
1.5.3 Sep 13, 2019
1.5.2 Apr 2, 2019
1.5.1 Feb 21, 2019
0.1.3 Sep 25, 2015

#448 in Data structures

Download history 293073/week @ 2021-01-21 305670/week @ 2021-01-28 304715/week @ 2021-02-04 313687/week @ 2021-02-11 337422/week @ 2021-02-18 338408/week @ 2021-02-25 324806/week @ 2021-03-04 342068/week @ 2021-03-11 330716/week @ 2021-03-18 363028/week @ 2021-03-25 333627/week @ 2021-04-01 370274/week @ 2021-04-08 360237/week @ 2021-04-15 355227/week @ 2021-04-22 347244/week @ 2021-04-29 309334/week @ 2021-05-06

1,482,115 downloads per month
Used in 8,640 crates (328 directly)

MIT/Apache

36KB
682 lines

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