sigp / superstruct

Rust library for versioned data types
https://sigp.github.io/superstruct/
Apache License 2.0
65 stars 3 forks source link

Capturing closures in mapping macros #31

Open michaelsproul opened 1 year ago

michaelsproul commented 1 year ago

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.