Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix EnumIter for enums with const generic #293

Merged
merged 1 commit into from
Jan 7, 2024

Conversation

PingPongun
Copy link
Contributor

Currently, EnumIter for struct with constant generic results in error E0747 (constant provided when a type was expected).
That's because generated iter struct looks sth like:

struct LanguageIter<LAUNCHER> {
        idx: usize,
        back_idx: usize,
        marker: ::core::marker::PhantomData<()>,
    }

for enum:

#[derive( EnumIter)]
enum Language<const LAUNCHER: bool> {...}

Which is ok for ordinary(type) generics, but for const generics iter struct definition has to look like:

struct LanguageIter<const LAUNCHER: bool> {...}

this PR makes EnumIter work with const generics, by using $impl_generics instead of $ty_generics for struct definition.
Also added const generic to enum in tests.

@Peternator7
Copy link
Owner

Looks good. Thanks for the fix :)

@Peternator7 Peternator7 merged commit a155e81 into Peternator7:master Jan 7, 2024
1 check passed
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.

None yet

2 participants