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 FromDeriveInputet 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
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 anattrs
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 adarling::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 aResult