Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: More functions for the Unwrap derive? #227

Open
T-O-R-U-S opened this issue Dec 29, 2022 · 1 comment
Open

Feature request: More functions for the Unwrap derive? #227

T-O-R-U-S opened this issue Dec 29, 2022 · 1 comment

Comments

@T-O-R-U-S
Copy link

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 the Option or Result variant is successful (Some/None).
  • .expect_<variant>(error_msg), an unwrap with a provided error message
  • .unwrap_<variant>_or(fallback), and unwrap that will return the fallback value if the Option or Result were None or Err
@JelteF
Copy link
Owner

JelteF commented Dec 29, 2022

Those suggested additions seem pretty reasonable. A semi-related issue was added here: #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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants