Skip to content

Add #[strum(transparent)] argument #258

@bobozaur

Description

@bobozaur

This crate is amazing for tackling a lot of boilerplate code and also ensuring variant name changes propagate to the trait implementations. I use AsRefStr and EnumString quite a lot.

However, a lot of times I've found myself in the situation of having something like this:

enum MyEnum {
    A,
    B,
    C,
    Other(String)
}

Afaik there's no way of propagating the AsRef<str> or FromStr implementations to the underlying String. What do you think about implementing a transparent argument to the attribute, similar to #[serde(transparent)] - only for one field provided in an unnamed/named fashion.

So then we could do:

#[derive(AsRefStr, EnumStr)]
enum MyEnum {
    A,
    B,
    C,
    #[strum(transparent)]
    Other(String)
}

I could try and pick this up if you like the idea. I think it would be handy for a lot of people.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions