TedDriggs / darling

A Rust proc-macro attribute parser
MIT License
983 stars 66 forks source link

Vec of Path #275

Closed PolyProgrammist closed 6 months ago

PolyProgrammist commented 7 months ago

Hi, is it possible to use:

[macro_name(field = [a, b])]

@TedDriggs

TedDriggs commented 7 months ago

Certainly would be possible, but by convention that's normally written in macros as #[macro_name(field(a, b))] - see #[derive(Debug, Clone, ...)] as an example. That's available as darling::util::PathList

TedDriggs commented 6 months ago

On further reflection, there are already two supported ways to handle this:

  1. Use darling::util::PathList as described above.
  2. Use #[darling(with = ...)] or #[darling(and_then = ...)] to accept a [syn::Expr] as the right-hand value and then validate that the expression is an array of paths or idents.

Given the existence of both these options, I am not inclined to add a new FromMeta impl.