Skip to content

Commit bc1aef3

Browse files
committed
Removed explicit lifetimes for get_mut. Fixed the doc test.
1 parent c1d716e commit bc1aef3

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/liballoc/arc.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ pub fn strong_count<T>(this: &Arc<T>) -> usize { this.inner().strong.load(SeqCst
252252
/// ```
253253
/// # #![feature(alloc)]
254254
/// extern crate alloc;
255+
/// # fn main() {
255256
/// use alloc::arc::{Arc, get_mut};
256257
///
257258
/// let mut x = Arc::new(3);
@@ -260,10 +261,11 @@ pub fn strong_count<T>(this: &Arc<T>) -> usize { this.inner().strong.load(SeqCst
260261
///
261262
/// let _y = x.clone();
262263
/// assert!(get_mut(&mut x).is_none());
264+
/// # }
263265
/// ```
264266
#[inline]
265267
#[unstable(feature = "alloc")]
266-
pub fn get_mut<'a, T>(this: &'a mut Arc<T>) -> Option<&'a mut T> {
268+
pub fn get_mut<T>(this: &mut Arc<T>) -> Option<&mut T> {
267269
if strong_count(this) == 1 && weak_count(this) == 0 {
268270
// This unsafety is ok because we're guaranteed that the pointer
269271
// returned is the *only* pointer that will ever be returned to T. Our

src/liballoc/rc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ pub fn try_unwrap<T>(rc: Rc<T>) -> Result<T, Rc<T>> {
324324
/// ```
325325
#[inline]
326326
#[unstable(feature = "alloc")]
327-
pub fn get_mut<'a, T>(rc: &'a mut Rc<T>) -> Option<&'a mut T> {
327+
pub fn get_mut<T>(rc: &mut Rc<T>) -> Option<&mut T> {
328328
if is_unique(rc) {
329329
let inner = unsafe { &mut **rc._ptr };
330330
Some(&mut inner.value)

0 commit comments

Comments
 (0)