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

feat: add unwrap_or and unwrap_default #4203

Merged
merged 6 commits into from
Oct 12, 2023
Merged

Conversation

Eikix
Copy link
Contributor

@Eikix Eikix commented Oct 4, 2023


This change is Reviewable

@Eikix Eikix marked this pull request as ready for review October 5, 2023 04:52
Copy link
Collaborator

@orizi orizi left a 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;

Copy link
Collaborator

@orizi orizi left a 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;

Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 1 of 1 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Eikix)

Copy link
Collaborator

@orizi orizi left a 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: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Eikix)

Copy link
Contributor

@gilbens-starkware gilbens-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Eikix)

Copy link
Contributor

@gilbens-starkware gilbens-starkware left a 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: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Eikix)

@orizi orizi enabled auto-merge October 12, 2023 16:43
@orizi orizi added this pull request to the merge queue Oct 12, 2023
Merged via the queue into starkware-libs:main with commit 52ec2d3 Oct 12, 2023
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

Successfully merging this pull request may close these issues.

3 participants