#enum #variants #iterator

enum-iterator

Tools to iterate over the variants of a field-less enum

9 releases (5 breaking)

0.7.0 Jul 25, 2021
0.6.0 Feb 17, 2020
0.5.0 Sep 29, 2019
0.4.0 Sep 27, 2019
0.2.0 Jul 2, 2018

#368 in Rust patterns

Download history 28579/week @ 2021-08-10 30337/week @ 2021-08-17 31182/week @ 2021-08-24 30337/week @ 2021-08-31 34112/week @ 2021-09-07 41385/week @ 2021-09-14 42160/week @ 2021-09-21 42137/week @ 2021-09-28 44668/week @ 2021-10-05 42778/week @ 2021-10-12 41321/week @ 2021-10-19 37635/week @ 2021-10-26 37971/week @ 2021-11-02 39601/week @ 2021-11-09 43668/week @ 2021-11-16 38397/week @ 2021-11-23

166,266 downloads per month
Used in 135 crates (42 directly)

0BSD license

10KB
112 lines

Overview

Tools to iterate over the variants of a field-less enum.

See the IntoEnumIterator trait.

Example

use enum_iterator::IntoEnumIterator;

#[derive(Debug, IntoEnumIterator, PartialEq)]
enum Day { Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday }

fn main() {
    assert_eq!(Day::into_enum_iter().next(), Some(Day::Monday));
    assert_eq!(Day::into_enum_iter().last(), Some(Day::Sunday));
}

Contribute

All contributions shall be licensed under the 0BSD license.


lib.rs:

Overview

Tools to iterate over the variants of a field-less enum.

See the [IntoEnumIterator] trait.

Example

use enum_iterator::IntoEnumIterator;

#[derive(Debug, IntoEnumIterator, PartialEq)]
enum Day { Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday }

fn main() {
    assert_eq!(Day::into_enum_iter().next(), Some(Day::Monday));
    assert_eq!(Day::into_enum_iter().last(), Some(Day::Sunday));
}

Contribute

All contributions shall be licensed under the 0BSD license.

Dependencies

~295–710KB
~18K SLoC