about summary refs log tree commit diff
path: root/src/libstd/cell.rs
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2013-12-05 17:37:02 -0800
committerPatrick Walton <pcwalton@mimiga.net>2013-12-10 17:55:09 -0800
commitfd7a513bef7fe3c6f5128cc53135facca37f23e5 (patch)
treebe733adb0aa531f7d4e1885b234c0bc489f02948 /src/libstd/cell.rs
parent61135080554d35cca151614c93693cb524fdffe0 (diff)
libstd: Remove `Cell` from the library.
Diffstat (limited to 'src/libstd/cell.rs')
-rw-r--r--src/libstd/cell.rs60
1 files changed, 0 insertions, 60 deletions
diff --git a/src/libstd/cell.rs b/src/libstd/cell.rs
index e49cf3e5303..280c79f1fd4 100644
--- a/src/libstd/cell.rs
+++ b/src/libstd/cell.rs
@@ -14,66 +14,6 @@ use prelude::*;
 use cast;
 use util::NonCopyable;
 
-
-/*
-A dynamic, mutable location.
-
-Similar to a mutable option type, but friendlier.
-*/
-
-#[no_freeze]
-#[deriving(Clone, DeepClone, Eq)]
-#[allow(missing_doc)]
-pub struct Cell<T> {
-    priv value: Option<T>
-}
-
-impl<T> Cell<T> {
-    /// Creates a new full cell with the given value.
-    pub fn new(value: T) -> Cell<T> {
-        Cell { value: Some(value) }
-    }
-
-    /// Yields the value, failing if the cell is empty.
-    pub fn take(&self) -> T {
-        let this = unsafe { cast::transmute_mut(self) };
-        if this.is_empty() {
-            fail!("attempt to take an empty cell");
-        }
-
-        this.value.take_unwrap()
-    }
-
-    /// Yields the value if the cell is full, or `None` if it is empty.
-    pub fn take_opt(&self) -> Option<T> {
-        let this = unsafe { cast::transmute_mut(self) };
-        this.value.take()
-    }
-
-    /// Returns true if the cell is empty and false if the cell is full.
-    pub fn is_empty(&self) -> bool {
-        self.value.is_none()
-    }
-}
-
-#[test]
-fn test_basic() {
-    let value_cell = Cell::new(~10);
-    assert!(!value_cell.is_empty());
-    let value = value_cell.take();
-    assert!(value == ~10);
-    assert!(value_cell.is_empty());
-}
-
-#[test]
-#[should_fail]
-fn test_take_empty() {
-    let value_cell: Cell<~int> = Cell::new(~0);
-    value_cell.take();
-    value_cell.take();
-}
-
-
 /// A mutable memory location with dynamically checked borrow rules
 #[no_freeze]
 pub struct RefCell<T> {