Document: You don't (Have to re-declare conditions on each repetition)
In my derive_builder
efforts, I have hit this unpleasantness:
struct FooBuilder {
$(
${define ... /* various complex conditions */ }
$fname: Option<$ftype>,
)
}
impl FooBuilder {
$(
${define ... /* those same complex conditions, copied again! */ }
pub fn $fname(&mut self, value: $ftype) -> &mut Self { ... }
)
pub fn build(&self) -> Result<Self, FooBuilderError> {
Ok(Self {
$(
${define ... /* those same complex conditions, copied a third time! */ }
$fname: self.$fname.clone().ok_or(...)?,
)
})
}
}
As you can see, it would be convenient if there were some way to extract those definitions into some common location. But right now, they are only scoped within a single repetition. I don't believe I can lift time to the top level, since they refer to field-specific things like fmeta
.
I wonder if this is something that #36 might be able to solve...?