about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-02-26 10:06:45 -0800
committerbors <bors@rust-lang.org>2013-02-26 10:06:45 -0800
commit565ec93fd3805d1c8d24fa10e51f6b95975c880f (patch)
tree6722e7ca5ce29d2abf19869475220d7ee1b282b7 /src/libstd
parent6439e286f90a34d96cec91d82f941f7572817939 (diff)
parentc9dd917fad8ead284643b9873de60e3df894fb59 (diff)
downloadrust-565ec93fd3805d1c8d24fa10e51f6b95975c880f.tar.gz
rust-565ec93fd3805d1c8d24fa10e51f6b95975c880f.zip
auto merge of #5110 : pcwalton/rust/and-const, r=pcwalton
r? @brson
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/cell.rs90
-rw-r--r--src/libstd/std.rc2
2 files changed, 1 insertions, 91 deletions
diff --git a/src/libstd/cell.rs b/src/libstd/cell.rs
deleted file mode 100644
index c8121daddab..00000000000
--- a/src/libstd/cell.rs
+++ /dev/null
@@ -1,90 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use core::option;
-use core::prelude::*;
-
-/// A dynamic, mutable location.
-///
-/// Similar to a mutable option type, but friendlier.
-
-pub struct Cell<T> {
-    mut value: Option<T>
-}
-
-/// Creates a new full cell with the given value.
-pub fn Cell<T>(value: T) -> Cell<T> {
-    Cell { value: Some(value) }
-}
-
-pub pure fn empty_cell<T>() -> Cell<T> {
-    Cell { value: None }
-}
-
-impl<T> Cell<T> {
-    /// Yields the value, failing if the cell is empty.
-    fn take() -> T {
-        if self.is_empty() {
-            fail!(~"attempt to take an empty cell");
-        }
-
-        let mut value = None;
-        value <-> self.value;
-        return option::unwrap(value);
-    }
-
-    /// Returns the value, failing if the cell is full.
-    fn put_back(value: T) {
-        if !self.is_empty() {
-            fail!(~"attempt to put a value back into a full cell");
-        }
-        self.value = Some(value);
-    }
-
-    /// Returns true if the cell is empty and false if the cell is full.
-    pure fn is_empty() -> bool {
-        self.value.is_none()
-    }
-
-    // Calls a closure with a reference to the value.
-    fn with_ref<R>(op: fn(v: &T) -> R) -> R {
-        let v = self.take();
-        let r = op(&v);
-        self.put_back(v);
-        r
-    }
-}
-
-#[test]
-fn test_basic() {
-    let value_cell = Cell(~10);
-    assert !value_cell.is_empty();
-    let value = value_cell.take();
-    assert value == ~10;
-    assert value_cell.is_empty();
-    value_cell.put_back(value);
-    assert !value_cell.is_empty();
-}
-
-#[test]
-#[should_fail]
-#[ignore(cfg(windows))]
-fn test_take_empty() {
-    let value_cell = empty_cell::<~int>();
-    value_cell.take();
-}
-
-#[test]
-#[should_fail]
-#[ignore(cfg(windows))]
-fn test_put_back_non_empty() {
-    let value_cell = Cell(~10);
-    value_cell.put_back(~20);
-}
diff --git a/src/libstd/std.rc b/src/libstd/std.rc
index 1ece8c17ff7..854abfdd112 100644
--- a/src/libstd/std.rc
+++ b/src/libstd/std.rc
@@ -29,6 +29,7 @@ not required in or otherwise suitable for the core library.
 #[allow(vecs_implicitly_copyable)];
 #[deny(non_camel_case_types)];
 #[allow(deprecated_self)];
+#[allow(deprecated_mutable_fields)];
 
 #[no_core];
 
@@ -53,7 +54,6 @@ pub mod uv_global_loop;
 
 pub mod c_vec;
 pub mod timer;
-pub mod cell;
 pub mod io_util;
 
 // Concurrency