Closed
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
}
}