Skip to content

improvements to option module #4465

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

Merged
merged 4 commits into from
Jan 13, 2013
Merged

improvements to option module #4465

merged 4 commits into from
Jan 13, 2013

Conversation

thestinger
Copy link
Contributor

I didn't add an equivalent free function for map_consume_default, mutate and mutate_default because as far as I can tell the only purpose of the free function versions is backwards compatibility.

The mutate methods are based on a need I have in my balanced tree implementation, which arises from doing it entirely without Copy/Clone. It factors out variations of the following pattern which occurs many times:

if foo.inner_option.is_some() {
    let inner = swap_unwrap(&mut foo.inner_option);
    inner = transform(inner);
    foo.inner_option = Some(inner);
}

catamorphism added a commit that referenced this pull request Jan 13, 2013
improvements to option module
@catamorphism catamorphism merged commit 7eae397 into rust-lang:incoming Jan 13, 2013
@catamorphism
Copy link
Contributor

Thanks!

@thestinger thestinger deleted the option branch January 14, 2013 06:29
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