3 unstable releases

Uses old Rust 2015

0.2.0 Dec 19, 2016
0.1.1 Dec 19, 2016
0.1.0 Dec 19, 2016

#1477 in Rust patterns

Download history 280/week @ 2023-11-27 301/week @ 2023-12-04 337/week @ 2023-12-11 393/week @ 2023-12-18 331/week @ 2023-12-25 331/week @ 2024-01-01 407/week @ 2024-01-08 320/week @ 2024-01-15 136/week @ 2024-01-22 146/week @ 2024-01-29 186/week @ 2024-02-05 196/week @ 2024-02-12 198/week @ 2024-02-19 284/week @ 2024-02-26 193/week @ 2024-03-04 90/week @ 2024-03-11

803 downloads per month
Used in 32 crates (4 directly)

MIT/Apache

17KB
323 lines

EitherN-rs

Build Status crates.io

Rust library allowing for quick, ad-hoc sum types.

Documentation


lib.rs:

Either enums over N different types.

Example

use either_n::Either7;

let either7 = match 1 {
    0 => Either7::One("a"),
    1 => Either7::Two(5u32),
    2 => Either7::Three("string".to_string()),
    3 => Either7::Four([1,2,3]),
    4 => Either7::Five([1,2,3,4,5,6]),
    6 => Either7::Six(()),
    _ => Either7::Seven(([()])),
};

assert_eq!(either7.as_ref().two(), Some(&5u32));
assert_eq!(either7.six(), None);

Thanks to @bluss for their Either crate.

No runtime deps

Features