derive_more
derive_more copied to clipboard
Feature request: More functions for the `Unwrap` derive?
I'd like to see more features from Rust's Option and Result added to the Unwrap derive.
A few notable ones:
.map_<variant>(callback_function), a map that will only execute if theOptionorResultvariant is successful (Some/None)..expect_<variant>(error_msg), anunwrapwith a provided error message.unwrap_<variant>_or(fallback), andunwrapthat will return the fallback value if theOptionorResultwereNoneorErr
Those suggested additions seem pretty reasonable. A semi-related issue was added here: https://github.com/JelteF/derive_more/pull/206
I do kind of worry that the amount of methods created by the derive will explode a bit, and thus impact compile time. So it might be nice to have some attributes to opt in/out of generating certain functions. Another option would be to make (some of) these separate derives.