]> git.lizzy.rs Git - rust.git/commitdiff
impl DerefMut for Cell<[T]>
authorF001 <changchun.fan@qq.com>
Thu, 7 Jun 2018 09:47:55 +0000 (17:47 +0800)
committerF001 <changchun.fan@qq.com>
Tue, 17 Jul 2018 03:34:19 +0000 (11:34 +0800)
src/libcore/cell.rs

index a85eee8545095bdc26274a343de9c6fd59d80685..7e2ece0f02c1c21eb2f908a9c00e4be3cfb74ffe 100644 (file)
@@ -559,6 +559,16 @@ fn deref(&self) -> &[Cell<T>] {
     }
 }
 
+#[unstable(feature = "as_cell", issue="43038")]
+impl<T> DerefMut for Cell<[T]> {
+    #[inline]
+    fn deref_mut(&mut self) -> &mut [Cell<T>] {
+        unsafe {
+            &mut *(self as *mut Cell<[T]> as *mut [Cell<T>])
+        }
+    }
+}
+
 /// A mutable memory location with dynamically checked borrow rules
 ///
 /// See the [module-level documentation](index.html) for more.