Crates.io | case_iterable |
lib.rs | case_iterable |
version | 0.2.0 |
source | src |
created_at | 2024-10-03 00:53:04.49527 |
updated_at | 2024-10-04 06:14:19.841898 |
description | A procedural macro to iterate over enum variants, ala Swift's CaseIterable |
homepage | |
repository | https://github.com/ianbrault/case_iterable |
max_upload_size | |
id | 1394799 |
size | 48,552 |
case_iterable
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"
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)