Currently superstruct uses a fn type for the closure passed to a mapping macro, meaning that variables can't be captured.
The reason we use fn is that it's a reliable type-hint that helps disambiguate things for the compiler. It would be interesting to investigate alternatives, like hinting only on the arguments/return value, or using something like a const or static assert.
Currently superstruct uses a
fn
type for the closure passed to a mapping macro, meaning that variables can't be captured.The reason we use
fn
is that it's a reliable type-hint that helps disambiguate things for the compiler. It would be interesting to investigate alternatives, like hinting only on the arguments/return value, or using something like a const or static assert.