Skip to content

Tests for non-unit variant enum rotations#1

Open
nullstalgia wants to merge 2 commits intogorilskij:masterfrom
nullstalgia:feat/allow_non_unit
Open

Tests for non-unit variant enum rotations#1
nullstalgia wants to merge 2 commits intogorilskij:masterfrom
nullstalgia:feat/allow_non_unit

Conversation

@nullstalgia
Copy link

@nullstalgia nullstalgia commented May 12, 2025

Ties into #1.

While experimenting with this macro, especially in a UI context, I found a repeated desire to have more than just unit variants cyclable in my enums.

Example:

#[derive(EnumRotate)]
enum Enum {
    MainMenu,
    Manual { page: u8 },
    Credits,
}

I'll often have Enums like this one, where there's either a flow or a collection of states where the persistence of data across those states isn't of importance.

So using calls to Default::default() for each field seemed like a reasonable compromise to me, although I would understand if you would prefer breaking this out into another trait/macro pair.

I didn't edit any documentation or try to tackle every Clippy suggestion I saw, as I wanted to get your feedback first. :)

Thanks for the useful macro!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant