#data-structure #no_std

no-std either

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

17 releases (9 stable)

1.5.0 Mar 25, 2018
1.4.0 Nov 14, 2017
1.3.0 Oct 15, 2017
1.1.0 Mar 25, 2017
0.1.3 Sep 25, 2015

#4 in Data structures

Download history 23972/week @ 2018-09-18 28324/week @ 2018-09-25 29922/week @ 2018-10-02 29904/week @ 2018-10-09 31681/week @ 2018-10-16 28635/week @ 2018-10-23 33993/week @ 2018-10-30 33840/week @ 2018-11-06 33805/week @ 2018-11-13 35373/week @ 2018-11-20 34125/week @ 2018-11-27 38041/week @ 2018-12-04 39225/week @ 2018-12-11

95,284 downloads per month
Used in 1,762 crates (75 directly)

MIT/Apache

22KB
394 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

  • optional serde 1.0+derive