GitXplorerGitXplorer
s

enum-iterator

public
104 stars
8 forks
1 issues

Commits

List of commits on branch master.
Unverified
2b1aaefe6de0ccea827b1376ebad12f3476662a9

Bump versions

sstephaneyfx committed 9 months ago
Unverified
e8e082e7d7745132177d3d1b09f53e7cc5a520b2

Go back to 0BSD license

sstephaneyfx committed 9 months ago
Unverified
f5960f1d98b2e4aafefbf2ce3a6b8ec0405e20a7

Bump versions

sstephaneyfx committed 9 months ago
Unverified
9598d98eef705b4e3e882ae469bda41141129491

Ensure license text is included in the packaged crates

ddavide125 committed 9 months ago
Unverified
7eab7e305f4153a2a07be3437264a19bbdbceee6

Fix formatting

sstephaneyfx committed a year ago
Verified
8efd9c931317f5d9d024a44bda246e4452a1fba7

Make next_cycle and previous_cycle not return Options

ffenhl committed a year ago

README

The README file for this repository.

Overview

Tools to iterate over the values of a type.

Examples

use enum_iterator::{all, cardinality, first, last, next, previous, reverse_all, Sequence};

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

assert_eq!(cardinality::<Day>(), 7);
assert_eq!(all::<Day>().collect::<Vec<_>>(), [
    Day::Monday,
    Day::Tuesday,
    Day::Wednesday,
    Day::Thursday,
    Day::Friday,
    Day::Saturday,
    Day::Sunday,
]);
assert_eq!(first::<Day>(), Some(Day::Monday));
assert_eq!(last::<Day>(), Some(Day::Sunday));
assert_eq!(next(&Day::Tuesday), Some(Day::Wednesday));
assert_eq!(previous(&Day::Wednesday), Some(Day::Tuesday));
assert_eq!(reverse_all::<Day>().collect::<Vec<_>>(), [
    Day::Sunday,
    Day::Saturday,
    Day::Friday,
    Day::Thursday,
    Day::Wednesday,
    Day::Tuesday,
    Day::Monday,
]);
use enum_iterator::{cardinality, first, last, Sequence};

#[derive(Debug, PartialEq, Sequence)]
struct Foo {
    a: bool,
    b: u8,
}

assert_eq!(cardinality::<Foo>(), 512);
assert_eq!(first::<Foo>(), Some(Foo { a: false, b: 0 }));
assert_eq!(last::<Foo>(), Some(Foo { a: true, b: 255 }));

Rust version

This crate tracks stable Rust. Minor releases may require a newer Rust version. Patch releases must not require a newer Rust version.

Contribute

All contributions shall be licensed under the 0BSD license.