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

FromMeta attribute for value which can be simple flag or String. #77

Closed
chtotut opened this issue May 3, 2019 · 1 comment
Closed
Labels

Comments

@chtotut
Copy link

chtotut commented May 3, 2019

Hi, I want to create attribute for:

#[derive(Test)]
pub struct Struct {
    #[test(value)]
    a: u8,
    #[test(value = "some expression")]
    b: u8,
}

value can be simple flag or String.
Is it possible?

@TedDriggs
Copy link
Owner

Would the type of value be an enum? If so, then this feels like a duplicate of #63, which would add support for associating the basic form of an enum with a specific variant.

Otherwise, you can implement this yourself without too much difficulty by filling in the following:

impl FromMeta for YourValue {
    fn from_word() -> darling::Result<Self> {}
    fn from_str(s: &str) -> darling::Result<Self> {}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants