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::take #7073

Merged
merged 1 commit into from
Jan 14, 2025
Merged

Conversation

hudem1
Copy link
Contributor

@hudem1 hudem1 commented Jan 13, 2025

Takes the value out of the option, leaving a [Option::None] in its place.

Example

#[test]
fn test_option_take() {
    let mut x = Option::Some(2);
    let y = x.take();
    assert_eq!(x, Option::None);
    assert_eq!(y, Option::Some(2));

    let mut x: Option<u32> = Option::None;
    let y = x.take();
    assert_eq!(x, Option::None);
    assert_eq!(y, Option::None);
}

@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 @hudem1)


a discussion (no related file):
@gilbens-starkware for 2nd eye.


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

    /// assert_eq!(y, Option::None);
    /// ```
    fn take(ref self: Option<T>) -> Option<T>;

@enitrat for doc.

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 @hudem1)

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

Copy link
Contributor

@enitrat enitrat 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 @hudem1)

@orizi orizi enabled auto-merge January 14, 2025 10:20
@orizi orizi added this pull request to the merge queue Jan 14, 2025
Merged via the queue into starkware-libs:main with commit 872a69f Jan 14, 2025
47 checks passed
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.

5 participants