1. That is a global static relationship rather than a local one dynamic one, which is the sense in which Go users use wrapping.
2. Idiomatic go type erases errors, so you're converting from `error` to `error`, hence type-directed conversions are not even remotely an option.
> That is a global static relationship rather than a local one dynamic one, which is the sense in which Go users use wrapping.
In practice, the error type will be defined quite close to where the conversion is applied, so the static nature of it doesn’t feel too big.
`map_err` does not need to be type-directed; you can use an arbitrary function or closure. An enum variant can be used as a function mapping from the variant type to the error type, but we can do any arbitrary transformation:
But the "idiomatic Go" way of doing things sounds a lot closer to anyhow in Rust, which provides convenience utilities for dealing with type-erased errors: