rotalubat

Crates.iorotalubat
lib.rsrotalubat
version1.0.2
created_at2026-01-21 19:34:40.287563+00
updated_at2026-01-23 10:26:18.174327+00
descriptionA derive macro for cycling through enum variants.
homepage
repositoryhttps://github.com/barafael/rotalubat
max_upload_size
id2059971
size26,288
Rafael Bachmann (barafael)

documentation

README

rotalubat

A derive macro for cycling through enum variants.

Usage

use rotalubat::Rotalubat;

#[derive(Rotalubat, PartialEq, Debug)]
enum SettingsPage {
    General,
    Account,
    Privacy,
}

fn main() {
    let mut page = SettingsPage::General;

    page.forward();
    assert_eq!(page, SettingsPage::Account);

    page.forward();
    assert_eq!(page, SettingsPage::Privacy);

    // wraps to first variant
    page.forward();
    assert_eq!(page, SettingsPage::General);

    // wraps to last variant
    page.backward();
    assert_eq!(page, SettingsPage::Privacy);
}

Limitations

Only unit enums are supported. Deriving Rotalubat to other data types will produce a compile error.

License

MIT or Apache-2.0

Commit count: 9

cargo fmt