about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2012-06-05 14:44:13 -0700
committerBrian Anderson <banderson@mozilla.com>2012-06-06 17:48:45 -0700
commitef32ffd0b1602ff87536508a7f75fd9b1510b4e9 (patch)
tree9c713054ff6f595708815a6d710753c277c37dca /src
parentbe83a12ff7bcc9c620bab8297654f6e006b50d6d (diff)
downloadrust-ef32ffd0b1602ff87536508a7f75fd9b1510b4e9.tar.gz
rust-ef32ffd0b1602ff87536508a7f75fd9b1510b4e9.zip
core: Remove swappable. Unused
Diffstat (limited to 'src')
-rw-r--r--src/libcore/core.rc2
-rw-r--r--src/libcore/swappable.rs98
-rw-r--r--src/test/run-pass/swappable-test.rs13
3 files changed, 0 insertions, 113 deletions
diff --git a/src/libcore/core.rc b/src/libcore/core.rc
index 84cebcceccd..6b4c7ad7d3c 100644
--- a/src/libcore/core.rc
+++ b/src/libcore/core.rc
@@ -43,7 +43,6 @@ export comm, task, future;
 export extfmt;
 export tuple;
 export to_str;
-export swappable;
 export dvec, dvec_iter;
 
 // NDM seems to be necessary for resolve to work
@@ -164,7 +163,6 @@ mod option_iter {
 }
 mod result;
 mod to_str;
-mod swappable;
 mod dvec;
 #[path="iter-trait"]
 mod dvec_iter {
diff --git a/src/libcore/swappable.rs b/src/libcore/swappable.rs
deleted file mode 100644
index 5df9b2c4846..00000000000
--- a/src/libcore/swappable.rs
+++ /dev/null
@@ -1,98 +0,0 @@
-export swappable;
-export unwrap;
-export methods;
-
-#[doc = "
-A value that may be swapped out temporarily while it is being processed
-and then replaced.  Swappables are most useful when working with unique
-values, which often cannot be mutated unless they are stored in the local
-stack frame to ensure memory safety.
-
-The type guarantees the invariant that the value is always \"swapped in\"
-except during the execution of the `swap()` and `with()` methods.
-"]
-type swappable<A> = {
-    mut o_t: option<A>
-};
-
-#[doc = "Create a swappable swapped in with a given initial value"]
-fn swappable<A>(+t: A) -> swappable<A> {
-    {mut o_t: some(t)}
-}
-
-#[doc = "Consumes a swappable and returns its contents without copying"]
-fn unwrap<A>(-s: swappable<A>) -> A {
-    let {o_t: o_t} <- s;
-    option::unwrap(o_t)
-}
-
-impl methods<A> for swappable<A> {
-    #[doc = "
-         Overwrites the contents of the swappable
-    "]
-    fn set(+a: A) {
-        self.o_t <- some(a);
-    }
-
-    #[doc = "
-         Invokes `f()` with the current value but replaces the
-         current value when complete.  Returns the result of `f()`.
-
-         Attempts to read or access the receiver while `f()` is executing
-         will fail dynamically.
-    "]
-    fn with<B>(f: fn(A) -> B) -> B {
-        let mut o_u = none;
-        self.swap { |t| o_u <- some(f(t)); t }
-        option::unwrap(o_u)
-    }
-
-    #[doc = "
-         Invokes `f()` with the current value and then replaces the
-         current value with the result of `f()`.
-
-         Attempts to read or access the receiver while `f()` is executing
-         will fail dynamically.
-    "]
-    fn swap(f: fn(-A) -> A) {
-        alt self.o_t {
-          none { fail "no value present---already swapped?"; }
-          some(_) {}
-        }
-
-        let mut o_t = none;
-        o_t <-> self.o_t;
-        self.o_t <- some(f(option::unwrap(o_t)));
-    }
-
-    #[doc = "True if there is a value present in this swappable"]
-    fn is_present() -> bool {
-        alt self.o_t {
-          none {false}
-          some(_) {true}
-        }
-    }
-
-    #[doc = "
-        Removes the value from the swappable.  Any further attempts
-        to use the swapabble without first invoking `set()` will fail.
-    "]
-    fn take() -> A {
-        alt self.o_t {
-          none { fail "swapped out"; }
-          some(_) {}
-        }
-
-        let mut o_t = none;
-        option::unwrap(o_t)
-    }
-}
-
-impl methods<A:copy> for swappable<A> {
-    #[doc = "
-        Copies out the contents of the swappable
-    "]
-    fn get() -> A {
-        self.o_t.get()
-    }
-}
\ No newline at end of file
diff --git a/src/test/run-pass/swappable-test.rs b/src/test/run-pass/swappable-test.rs
deleted file mode 100644
index ee344648901..00000000000
--- a/src/test/run-pass/swappable-test.rs
+++ /dev/null
@@ -1,13 +0,0 @@
-import swappable::{swappable, methods};
-
-fn main() {
-    let d = swappable(3);
-    assert d.get() == 3;
-    d.set(4);
-    assert d.get() == 4;
-    d.swap { |i| i + 1 };
-    assert d.get() == 5;
-    assert d.with { |i| i + 1 } == 6;
-    assert d.get() == 5;
-    assert swappable::unwrap(d) == 5;
-}
\ No newline at end of file