@@ -387,50 +387,6 @@ impl<'mutex, T: ?Sized> MutexGuard<'mutex, T> {
387
387
}
388
388
} )
389
389
}
390
-
391
- /// Transform this guard to hold a sub-borrow of the original data.
392
- ///
393
- /// Applies the supplied closure to the data, returning a new lock
394
- /// guard referencing the borrow returned by the closure.
395
- ///
396
- /// # Examples
397
- ///
398
- /// ```rust
399
- /// # #![feature(guard_map)]
400
- /// # use std::sync::{Mutex, MutexGuard};
401
- /// let x = Mutex::new(vec![1, 2]);
402
- ///
403
- /// {
404
- /// let mut y = MutexGuard::map(x.lock().unwrap(), |v| &mut v[0]);
405
- /// *y = 3;
406
- /// }
407
- ///
408
- /// assert_eq!(&*x.lock().unwrap(), &[3, 2]);
409
- /// ```
410
- #[ unstable( feature = "guard_map" ,
411
- reason = "recently added, needs RFC for stabilization" ,
412
- issue = "27746" ) ]
413
- pub fn map < U : ?Sized , F > ( this : Self , cb : F ) -> MutexGuard < ' mutex , U >
414
- where F : FnOnce ( & ' mutex mut T ) -> & ' mutex mut U
415
- {
416
- // Compute the new data while still owning the original lock
417
- // in order to correctly poison if the callback panics.
418
- let data = unsafe { ptr:: read ( & this. __data ) } ;
419
- let new_data = cb ( data) ;
420
-
421
- // We don't want to unlock the lock by running the destructor of the
422
- // original lock, so just read the fields we need and forget it.
423
- let ( poison, lock) = unsafe {
424
- ( ptr:: read ( & this. __poison ) , ptr:: read ( & this. __lock ) )
425
- } ;
426
- mem:: forget ( this) ;
427
-
428
- MutexGuard {
429
- __lock : lock,
430
- __data : new_data,
431
- __poison : poison
432
- }
433
- }
434
390
}
435
391
436
392
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -469,7 +425,7 @@ mod tests {
469
425
use prelude:: v1:: * ;
470
426
471
427
use sync:: mpsc:: channel;
472
- use sync:: { Arc , Mutex , StaticMutex , Condvar , MutexGuard } ;
428
+ use sync:: { Arc , Mutex , StaticMutex , Condvar } ;
473
429
use sync:: atomic:: { AtomicUsize , Ordering } ;
474
430
use thread;
475
431
@@ -713,19 +669,4 @@ mod tests {
713
669
let comp: & [ i32 ] = & [ 4 , 2 , 5 ] ;
714
670
assert_eq ! ( & * mutex. lock( ) . unwrap( ) , comp) ;
715
671
}
716
-
717
- #[ test]
718
- fn test_mutex_guard_map_panic ( ) {
719
- let mutex = Arc :: new ( Mutex :: new ( vec ! [ 1 , 2 ] ) ) ;
720
- let mutex2 = mutex. clone ( ) ;
721
-
722
- thread:: spawn ( move || {
723
- let _ = MutexGuard :: map :: < usize , _ > ( mutex2. lock ( ) . unwrap ( ) , |_| panic ! ( ) ) ;
724
- } ) . join ( ) . unwrap_err ( ) ;
725
-
726
- match mutex. lock ( ) {
727
- Ok ( r) => panic ! ( "Lock on poisioned Mutex is Ok: {:?}" , & * r) ,
728
- Err ( _) => { }
729
- } ;
730
- }
731
672
}
0 commit comments