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 FromMeta for Vec<LitStr> & co #265

Merged
merged 3 commits into from
Feb 14, 2024

Conversation

Ten0
Copy link
Contributor

@Ten0 Ten0 commented Feb 8, 2024

This allows parsing meta attributes of the form #[foo(bar = ["a", "b", "c"])] to Vec<syn::LitStr> (and same for other Lits).

Copy link
Owner

@TedDriggs TedDriggs left a comment

Choose a reason for hiding this comment

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

Why are these impls needed - wouldn't these all be valid Expr, or ExprArray? I'm not opposed to merging this, but I do recall there being some issue with Vec in the past, and I'm therefore wary of piecemeal adding Vec impls.

Update: I think I remember the backstory now.

I avoided adding a impl<T: FromMeta> FromMeta for Vec<T> because different lists would have different manifestations in the AST. Adding these specific impls is useful because it lets someone take a list of homogenous literals, rather than having to accept an Expr and then check it using and_then

I am okay with merging this once the format errors are fixed.

@TedDriggs TedDriggs merged commit a43190f into TedDriggs:master Feb 14, 2024
24 checks 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.

2 participants