| Crates.io | variter |
| lib.rs | variter |
| version | 0.3.0 |
| created_at | 2021-01-28 04:27:50.568407+00 |
| updated_at | 2021-02-15 20:56:55.293161+00 |
| description | Declarative macro-derivable trait for iterating over field-less enum type variants |
| homepage | https://github.com/deus-x-mackina/variter |
| repository | https://github.com/deus-x-mackina/variter |
| max_upload_size | |
| id | 347554 |
| size | 26,374 |
variter is a Rust crate that exports some simple tools for iterating
over enum types with zero or more variants that have no fields.
use variter::{VarIter, derive_var_iter};
derive_var_iter! {
#[derive(Debug)]
enum Greeting {
Hello,
Hola,
Bonjour,
}
}
fn main() {
for greeting in Greeting::ALL_VARIANTS {
println!("{:?}", greeting);
}
}
If you're familiar with the Swift language, it's similar to using the
compiler-synthesized CaseIterable protocol conformance.
See the module documentation for more information!
Add variter as a dependency in your Cargo.toml file:
[dependencies]
# ...
variter = "0.2"
foreign_impls (default): include implementions of VarIter on stable core types.std (default): if foreign_impls is turned on, VarIter implementations are included for stable std types.no_std SupportGiven the simplicity of the crate, no_std support can be toggled through the
default-features = false flag in your Cargo.toml dependency table.
[dependencies]
# ...
variter = { version = "0.2", default-features = false }
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.