From bc1aef3e7b46db3d3eee4eca80f6462f8a56bbeb Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Sat, 4 Apr 2015 18:54:23 -0400 Subject: [PATCH] Removed explicit lifetimes for `get_mut`. Fixed the doc test. --- src/liballoc/arc.rs | 4 +++- src/liballoc/rc.rs | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index 0a66327b5ac..68bde147611 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -252,6 +252,7 @@ pub fn strong_count(this: &Arc) -> usize { this.inner().strong.load(SeqCst /// ``` /// # #![feature(alloc)] /// extern crate alloc; +/// # fn main() { /// use alloc::arc::{Arc, get_mut}; /// /// let mut x = Arc::new(3); @@ -260,10 +261,11 @@ pub fn strong_count(this: &Arc) -> usize { this.inner().strong.load(SeqCst /// /// let _y = x.clone(); /// assert!(get_mut(&mut x).is_none()); +/// # } /// ``` #[inline] #[unstable(feature = "alloc")] -pub fn get_mut<'a, T>(this: &'a mut Arc) -> Option<&'a mut T> { +pub fn get_mut(this: &mut Arc) -> Option<&mut T> { if strong_count(this) == 1 && weak_count(this) == 0 { // This unsafety is ok because we're guaranteed that the pointer // returned is the *only* pointer that will ever be returned to T. Our diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 7cdd4888426..56822cfe28a 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -324,7 +324,7 @@ pub fn try_unwrap(rc: Rc) -> Result> { /// ``` #[inline] #[unstable(feature = "alloc")] -pub fn get_mut<'a, T>(rc: &'a mut Rc) -> Option<&'a mut T> { +pub fn get_mut(rc: &mut Rc) -> Option<&mut T> { if is_unique(rc) { let inner = unsafe { &mut **rc._ptr }; Some(&mut inner.value)