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

Support parsing via TryFrom<MetaItem> #12

Open
TedDriggs opened this issue May 1, 2017 · 1 comment
Open

Support parsing via TryFrom<MetaItem> #12

TedDriggs opened this issue May 1, 2017 · 1 comment

Comments

@TedDriggs
Copy link

It would be useful to write something like...

pub struct Lorem {
    #[attire(meta_item)]
    ipsum: Dolor
}

impl TryFrom<syn::MetaItem> for Dolor {
    type Error = String;

    fn try_from(v: syn::MetaItem) -> Result<Self, Self::Error> {
        // do stuff.
    }
}

In parallel, it'd be useful if prom-attire could generate such implementations. This would make it easier to create reusable parts that adhered to the normal attribute format.

@TedDriggs
Copy link
Author

TedDriggs commented May 1, 2017

A related enhancement would be #[attire(meta_item="path::to::function")]. That would enable overrides for cases where the type was remote. This might best be done with a trait defined by the prom-attire crate and a blanket impl of that trait for TryFrom<syn::MetaItem>.

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

No branches or pull requests

1 participant