case_iterable

Crates.iocase_iterable
lib.rscase_iterable
version0.2.0
sourcesrc
created_at2024-10-03 00:53:04.49527
updated_at2024-10-04 06:14:19.841898
descriptionA procedural macro to iterate over enum variants, ala Swift's CaseIterable
homepage
repositoryhttps://github.com/ianbrault/case_iterable
max_upload_size
id1394799
size48,552
Ian Brault (ianbrault)

documentation

https://github.com/ianbrault/case_iterable

README

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.
Commit count: 7

cargo fmt