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(corelib): OptionTrait::is_some_and #6927

Merged
merged 2 commits into from
Dec 26, 2024

Conversation

julio4
Copy link
Contributor

@julio4 julio4 commented Dec 25, 2024

Returns true if the Option is Option::Some and the value inside of it matches a predicate.

Examples

assert_eq!(Option::Some(2_u8).is_some_and(|x| x > 1), true);
assert_eq!(Option::Some(0_u8).is_some_and(|x| x > 1), false);

let option: Option<u8> = Option::None;
assert_eq!(option.is_some_and(|x| x > 1), false);

@reviewable-StarkWare
Copy link

This change is Reviewable

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 2 of 2 files at r1, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @julio4)


a discussion (no related file):
@TomerStarkware for 2nd eye.

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.

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @julio4)


corelib/src/option.cairo line 216 at r1 (raw file):

    fn is_some_and<F, +Drop<F>, impl func: core::ops::FnOnce<F, (T,)>[Output: bool]>(
        self: Option<T>, f: F,
    ) -> bool;

Suggestion:

    #[must_use]
    fn is_some_and<F, +Drop<F>, +core::ops::FnOnce<F, (T,)>[Output: bool]>(
        self: Option<T>, f: F,
    ) -> bool;

Copy link
Contributor Author

@julio4 julio4 left a comment

Choose a reason for hiding this comment

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

Reviewable status: 1 of 2 files reviewed, 1 unresolved discussion (waiting on @orizi)


corelib/src/option.cairo line 216 at r1 (raw file):

    fn is_some_and<F, +Drop<F>, impl func: core::ops::FnOnce<F, (T,)>[Output: bool]>(
        self: Option<T>, f: F,
    ) -> bool;

Done.

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

Copy link
Collaborator

@TomerStarkware TomerStarkware 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 @julio4)

@orizi orizi added this pull request to the merge queue Dec 26, 2024
Merged via the queue into starkware-libs:main with commit 057dd03 Dec 26, 2024
47 checks passed
@julio4 julio4 deleted the feat/option_is_some_and branch February 5, 2025 10:58
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.

4 participants