about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGraydon Hoare <graydon@mozilla.com>2012-08-13 19:06:57 -0700
committerGraydon Hoare <graydon@mozilla.com>2012-08-13 19:08:02 -0700
commit36883186ab88e7b39ea2cb0f47c2c8999840663e (patch)
treefd27a1819bd110cc11977286adb7b033197470e1
parentbc6eaf2acba7f71422e0540b0abbb7828f00b68f (diff)
downloadrust-36883186ab88e7b39ea2cb0f47c2c8999840663e.tar.gz
rust-36883186ab88e7b39ea2cb0f47c2c8999840663e.zip
De-mode core::future.
-rw-r--r--src/libcore/future.rs34
-rw-r--r--src/libcore/task.rs6
-rw-r--r--src/libstd/arc.rs2
-rw-r--r--src/libstd/test.rs2
-rw-r--r--src/rustdoc/markdown_writer.rs2
5 files changed, 25 insertions, 21 deletions
diff --git a/src/libcore/future.rs b/src/libcore/future.rs
index 361f41ba21b..79259c785fe 100644
--- a/src/libcore/future.rs
+++ b/src/libcore/future.rs
@@ -1,3 +1,7 @@
+// NB: transitionary, de-mode-ing.
+#[forbid(deprecated_mode)];
+#[forbid(deprecated_pattern)];
+
 /*!
  * A type representing values that may be computed concurrently and
  * operations for working with them.
@@ -37,13 +41,13 @@ impl<A:copy send> future<A> {
     fn get() -> A {
         //! Get the value of the future
 
-        get(self)
+        get(&self)
     }
 
-    fn with<B>(blk: fn(A) -> B) -> B {
+    fn with<B>(blk: fn((&A)) -> B) -> B {
         //! Work with the value without copying it
 
-        with(self, blk)
+        with(&self, blk)
     }
 }
 
@@ -64,7 +68,7 @@ macro_rules! move_it {
     {$x:expr} => { unsafe { let y <- *ptr::addr_of($x); y } }
 }
 
-fn from_port<A:send>(-port: future_pipe::client::waiting<A>) -> future<A> {
+fn from_port<A:send>(+port: future_pipe::client::waiting<A>) -> future<A> {
     #[doc = "
     Create a future from a port
 
@@ -110,13 +114,13 @@ fn spawn<A:send>(+blk: fn~() -> A) -> future<A> {
     }))
 }
 
-fn get<A:copy>(future: future<A>) -> A {
+fn get<A:copy>(future: &future<A>) -> A {
     //! Get the value of the future
 
-    do with(future) |v| { v }
+    do with(future) |v| { *v }
 }
 
-fn with<A,B>(future: future<A>, blk: fn(A) -> B) -> B {
+fn with<A,B>(future: &future<A>, blk: fn((&A)) -> B) -> B {
     //! Work with the value without copying it
 
     let v = match copy future.v {
@@ -127,7 +131,7 @@ fn with<A,B>(future: future<A>, blk: fn(A) -> B) -> B {
         v
       }
     };
-    blk(*v)
+    blk(v)
 }
 
 proto! future_pipe {
@@ -139,7 +143,7 @@ proto! future_pipe {
 #[test]
 fn test_from_value() {
     let f = from_value(~"snail");
-    assert get(f) == ~"snail";
+    assert get(&f) == ~"snail";
 }
 
 #[test]
@@ -147,14 +151,14 @@ fn test_from_port() {
     let (po, ch) = future_pipe::init();
     future_pipe::server::completed(ch, ~"whale");
     let f = from_port(po);
-    assert get(f) == ~"whale";
+    assert get(&f) == ~"whale";
 }
 
 #[test]
 fn test_from_fn() {
     let f = fn@() -> ~str { ~"brail" };
     let f = from_fn(f);
-    assert get(f) == ~"brail";
+    assert get(&f) == ~"brail";
 }
 
 #[test]
@@ -166,19 +170,19 @@ fn test_interface_get() {
 #[test]
 fn test_with() {
     let f = from_value(~"nail");
-    assert with(f, |v| v) == ~"nail";
+    assert with(&f, |v| *v) == ~"nail";
 }
 
 #[test]
 fn test_interface_with() {
     let f = from_value(~"kale");
-    assert f.with(|v| v) == ~"kale";
+    assert f.with(|v| *v) == ~"kale";
 }
 
 #[test]
 fn test_spawn() {
     let f = spawn(|| ~"bale");
-    assert get(f) == ~"bale";
+    assert get(&f) == ~"bale";
 }
 
 #[test]
@@ -186,5 +190,5 @@ fn test_spawn() {
 #[ignore(cfg(target_os = "win32"))]
 fn test_futurefail() {
     let f = spawn(|| fail);
-    let _x: ~str = get(f);
+    let _x: ~str = get(&f);
 }
diff --git a/src/libcore/task.rs b/src/libcore/task.rs
index 244feb3f713..230e9173dcb 100644
--- a/src/libcore/task.rs
+++ b/src/libcore/task.rs
@@ -409,7 +409,7 @@ impl task_builder {
         do self.future_result(|+r| { result = some(r); }).spawn {
             comm::send(ch, f());
         }
-        match future::get(option::unwrap(result)) {
+        match future::get(&option::unwrap(result)) {
             success => result::ok(comm::recv(po)),
             failure => result::err(())
         }
@@ -1704,13 +1704,13 @@ fn test_add_wrapper() {
 fn test_future_result() {
     let mut result = none;
     do task().future_result(|+r| { result = some(r); }).spawn { }
-    assert future::get(option::unwrap(result)) == success;
+    assert future::get(&option::unwrap(result)) == success;
 
     result = none;
     do task().future_result(|+r| { result = some(r); }).unlinked().spawn {
         fail;
     }
-    assert future::get(option::unwrap(result)) == failure;
+    assert future::get(&option::unwrap(result)) == failure;
 }
 
 #[test] #[should_fail] #[ignore(cfg(windows))]
diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs
index 03261ec0025..847e08083ef 100644
--- a/src/libstd/arc.rs
+++ b/src/libstd/arc.rs
@@ -429,7 +429,7 @@ mod tests {
             }
         }
         // Wait for children to pass their asserts
-        for vec::each(children) |r| { future::get(r); }
+        for vec::each(children) |r| { future::get(&r); }
         // Wait for writer to finish
         p.recv();
         do arc.read |num| { assert *num == 10; }
diff --git a/src/libstd/test.rs b/src/libstd/test.rs
index 4f6d04a5dd7..104826afbac 100644
--- a/src/libstd/test.rs
+++ b/src/libstd/test.rs
@@ -391,7 +391,7 @@ fn run_test(+test: test_desc, monitor_ch: comm::chan<monitor_msg>) {
         task::task().unlinked().future_result(|+r| {
             result_future = some(r);
         }).spawn(testfn);
-        let task_result = future::get(option::unwrap(result_future));
+        let task_result = future::get(&option::unwrap(result_future));
         let test_result = calc_result(test, task_result == task::success);
         comm::send(monitor_ch, (copy test, test_result));
     };
diff --git a/src/rustdoc/markdown_writer.rs b/src/rustdoc/markdown_writer.rs
index 139ea0f36f5..3f33780ed2f 100644
--- a/src/rustdoc/markdown_writer.rs
+++ b/src/rustdoc/markdown_writer.rs
@@ -274,7 +274,7 @@ fn future_writer_factory(
         do task::spawn {
             let (writer, future) = future_writer();
             comm::send(writer_ch, writer);
-            let s = future::get(future);
+            let s = future::get(&future);
             comm::send(markdown_ch, (page, s));
         }
         comm::recv(writer_po)