Skip to content

ianbrault/case_iterable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

case_iterable

License: GPL v3 Crates.io

Installation

case_iterable can be installed with cargo:

$ cargo add case_iterable

or by manually adding it to your Cargo.toml:

[dependencies]
case_iterable = "0.2.0"

Usage

use case_iterable::CaseIterable;

#[derive(CaseIterable)]
enum Foo {
    A,
    Bar,
    Chocolate,
}

for variant in Foo::all_cases() {
    // Foo::A
    // Foo::Bar
    // Foo::Chocolate
}

// also exposes the next function used for the iterator
let x = Foo::Bar;
let y = x.next();  // Some(Foo::Chocolate)

License

Licensed under GNU General Public License, Version 3.0 This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

About

Rust procedural macro to iterate over enum variants, ala Swift's CaseIterable

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages