TedDriggs / darling

A Rust proc-macro attribute parser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support `with` on magic field `attrs`

TedDriggs opened this issue · comments

In colin-kiegel/rust-derive-builder#310, @dtolnay pointed out some clunky code that handles “distribution and unnesting” of attributes. The Options struct is forced to have an attrs field that is only temporarily used.

This can be avoided by allowing the deriver of FromDeriveInput et alia to provide a conversion function that takes attributes and returns a darling::Result<?>

This function must participate in the error accumulator behavior of the rest of the derived impl, so it must be invoked before the error check, and we’ll need a new local variable for the output.

with makes more sense than the postfix items, since this must allow failure and doesn’t itself take in a Result