Skip to content

cgaebel/enumiter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EnumIter

crates.io

Build Status

A simple iterator through the different variants in an enum.

Example

  use enumiter::{enum_iter, AllVariantsTakeNoParameters};

  #[derive(Clone, Copy, PartialEq, Eq, Debug)]
  enum Test {
    One,
    Two,
    Three,
  }

  unsafe impl AllVariantsTakeNoParameters for Test {}

  #[test]
  fn it_works() {
    let mut vals = Vec::new();

    let _ = Test::Two; // ignore dead code warning.

    for x in enum_iter(Test::One, Test::Three) {
      vals.push(x);
    }

    assert_eq!(format!("{:?}", vals), "[One, Two, Three]");
  }

Documentation

See the very thorough API Docs.

About

An iterator through the different variants of an enum.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages