]> git.lizzy.rs Git - rust.git/blobdiff - src/librustrt/exclusive.rs
rollup merge of #17355 : gamazeps/issue17210
[rust.git] / src / librustrt / exclusive.rs
index 62313965768a6e623b545a4b83819ad1ccc579ea..d40f149a2a1f8316a5cd4514efae81eb26d00d14 100644 (file)
@@ -10,7 +10,7 @@
 
 use core::prelude::*;
 
-use core::ty::Unsafe;
+use core::cell::UnsafeCell;
 use mutex;
 
 /// An OS mutex over some data.
 /// >           as part of `libsync` should almost always be favored.
 pub struct Exclusive<T> {
     lock: mutex::NativeMutex,
-    data: Unsafe<T>,
+    data: UnsafeCell<T>,
 }
 
 /// An RAII guard returned via `lock`
-pub struct ExclusiveGuard<'a, T> {
+pub struct ExclusiveGuard<'a, T:'a> {
     // FIXME #12808: strange name to try to avoid interfering with
     // field accesses of the contained type via Deref
     _data: &'a mut T,
@@ -39,7 +39,7 @@ impl<T: Send> Exclusive<T> {
     pub fn new(user_data: T) -> Exclusive<T> {
         Exclusive {
             lock: unsafe { mutex::NativeMutex::new() },
-            data: Unsafe::new(user_data),
+            data: UnsafeCell::new(user_data),
         }
     }
 
@@ -107,7 +107,7 @@ fn exclusive_new_arc() {
                 });
             };
 
-            for f in futures.mut_iter() { f.recv() }
+            for f in futures.iter_mut() { f.recv() }
 
             assert_eq!(**total.lock(), num_tasks * count);
         }