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

Add EnumDiscriminants Trait and related Macro impl #377

Conversation

vpochapuis
Copy link
Contributor

This PR has for goal to implement and resolve #376 as well as #176

Copy link

@mohe2015 mohe2015 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested my crate with the new changes.

@Peternator7 Peternator7 merged commit 1454ced into Peternator7:master Sep 29, 2024
@yescallop
Copy link

I should note that these changes break the following user code:

#[derive(EnumDiscriminants)]
#[strum_discriminants(name(PrivateDiscriminants), vis(pub(self)))]
pub enum PublicEnum {
    Variant0(bool),
    Variant1 { a: bool },
}

The error message is:

error[E0446]: private type `PrivateDiscriminants` in public interface

This is because the IntoDiscriminant impl of PublicEnum leaks the private PrivateDiscriminants type. Should we maybe exclude the IntoDiscriminant impl when the parent enum is public and the generated enum is private?

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.

Proposal to add a trait for EnumDiscriminants
4 participants