]> git.lizzy.rs Git - rust.git/commitdiff
remove "get_with" method
authorF001 <changchun.fan@qq.com>
Sat, 26 May 2018 11:55:40 +0000 (19:55 +0800)
committerF001 <changchun.fan@qq.com>
Tue, 17 Jul 2018 03:34:19 +0000 (11:34 +0800)
src/libcore/cell.rs
src/test/run-pass/rfc-1789-as-cell/from-mut.rs

index 3536588f9dfaab30f95562088c0a37aecbc1a320..78ae1346175877e21980019d20198a2ff5353592 100644 (file)
@@ -510,8 +510,8 @@ pub fn get_mut(&mut self) -> &mut T {
     /// use std::cell::Cell;
     /// let slice: &mut [i32] = &mut [1,2,3];
     /// let cell_slice: &Cell<[i32]> = Cell::from_mut(slice);
-    ///
-    /// assert_eq!(cell_slice.get_with(|v|v.len()), 3)
+    /// let slice_cell : &[Cell<i32>] = &cell_slice[..];
+    /// assert_eq!(slice_cell.len(), 3)
     /// ```
     #[inline]
     #[unstable(feature = "as_cell", issue="43038")]
@@ -520,28 +520,6 @@ pub fn from_mut<'a>(t: &'a mut T) -> &'a Cell<T> {
             &*(t as *mut T as *const Cell<T>)
         }
     }
-
-    /// Returns a value by applying a function on contained value
-    ///
-    /// # Examples
-    ///
-    /// ```
-    /// #![feature(as_cell)]
-    /// use std::cell::Cell;
-    /// let c : Cell<Vec<i32>> = Cell::new(vec![1,2,3]);
-    /// let sum : i32 = c.get_with(|v|v.iter().sum());
-    /// assert_eq!(sum, 6_i32);
-    /// ```
-    #[inline]
-    #[unstable(feature = "as_cell", issue="43038")]
-    pub fn get_with<U, F>(&self, f: F) -> U
-    where
-        F: Fn(&T) -> U, U: 'static
-    {
-        unsafe {
-            f(&*self.value.get())
-        }
-    }
 }
 
 impl<T: Default> Cell<T> {
index 33257124f57aeb9fd6c8d028b8c88643a2a7dd8b..28b6d8213f714fdbcbed47a94c15db502b0dea8c 100644 (file)
@@ -15,8 +15,6 @@
 fn main() {
     let slice: &mut [i32] = &mut [1,2,3];
     let cell_slice: &Cell<[i32]> = Cell::from_mut(slice);
-    assert_eq!(cell_slice.get_with(|v|v.len()), 3);
-
     let sub_slice : &[Cell<i32>] = &cell_slice[1..];
     assert_eq!(sub_slice.len(), 2);
 }