-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Description
With the new borrow-checker, &mut T
is noncopyable, so the following functions are now safe:
fn get_mut_ref<'a,T>(x: &'a mut Option<T>) -> &'a mut T {
match x {
&Some(ref mut inner) => inner,
&None => fail!(),
}
}
fn map_mut<T,U>(x: &mut Option<T>, blk: &fn(&mut T) -> U) -> Option<U> {
match x {
&Some(ref mut inner) => Some(blk(inner)),
&None => None
}
}
Metadata
Metadata
Assignees
Labels
A-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.