-
Notifications
You must be signed in to change notification settings - Fork 575
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
feat: add unwrap_or and unwrap_default #4203
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @Eikix)
corelib/src/option.cairo
line 22 at r1 (raw file):
fn unwrap_or<+Drop<T>>(self: Option<T>, default: T) -> T; /// Returns x if Option is Option::some(x), otherwise returns Default::<T>::default() fn unwrap_or_default<+Default<T>>(self: Option<T>) -> T;
Suggestion:
fn is_none(self: @Option<T>) -> bool;
/// Returns x if Option is Option::some(x), otherwise returns the provided default value.
fn unwrap_or<+Drop<T>>(self: Option<T>, default: T) -> T;
/// Returns x if Option is Option::some(x), otherwise returns Default::<T>::default().
fn unwrap_or_default<+Default<T>>(self: Option<T>) -> T;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @Eikix)
corelib/src/option.cairo
line 22 at r2 (raw file):
fn unwrap_or<+Drop<T>>(self: Option<T>, default: T) -> T; /// Returns x if Option is Option::some(x), otherwise returns Default::<T>::default(). fn unwrap_or_default<+Default<T>>(self: Option<T>) -> T;
just more conforming to the rest of the doc.
Suggestion:
/// If `self` is `Option::Some(x)`, returns `x`. Otherwise, returns the provided default.
fn unwrap_or<+Drop<T>>(self: Option<T>, default: T) -> T;
/// If `self` is `Option::Some(x)`, returns `x`. Otherwise, returns `Default::<T>::default()`.
fn unwrap_or_default<+Default<T>>(self: Option<T>) -> T;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r3, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @Eikix)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gilbens-starkware for 2nd eye
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @Eikix)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @Eikix)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r3, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @Eikix)
This change is