about summary refs log tree commit diff
path: root/src/libstd/sync
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2015-04-01 11:12:30 -0400
committerNiko Matsakis <niko@alum.mit.edu>2015-04-01 14:41:21 -0400
commitcade32acf6f5ff209ee082d70350d9bc0362985a (patch)
tree79c4fd475c0b8e9f75972eb505800399025fba06 /src/libstd/sync
parented63d32651105e56afceb94cbb86f115db235825 (diff)
downloadrust-cade32acf6f5ff209ee082d70350d9bc0362985a.tar.gz
rust-cade32acf6f5ff209ee082d70350d9bc0362985a.zip
Remove `Thunk` struct and `Invoke` trait; change `Thunk` to be an alias
for `Box<FnBox()>`. I found the alias was still handy because it is
shorter than the fully written type.

This is a [breaking-change]: convert code using `Invoke` to use `FnBox`,
which is usually pretty straight-forward. Code using thunk mostly works
if you change `Thunk::new => Box::new` and `foo.invoke(arg)` to
`foo(arg)`.
Diffstat (limited to 'src/libstd/sync')
-rw-r--r--src/libstd/sync/future.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/libstd/sync/future.rs b/src/libstd/sync/future.rs
index b2afe28fed4..2cdde1aca9e 100644
--- a/src/libstd/sync/future.rs
+++ b/src/libstd/sync/future.rs
@@ -36,6 +36,7 @@
 use core::prelude::*;
 use core::mem::replace;
 
+use boxed::Box;
 use self::FutureState::*;
 use sync::mpsc::{Receiver, channel};
 use thunk::Thunk;
@@ -84,7 +85,7 @@ impl<A> Future<A> {
                 match replace(&mut self.state, Evaluating) {
                     Forced(_) | Evaluating => panic!("Logic error."),
                     Pending(f) => {
-                        self.state = Forced(f.invoke(()));
+                        self.state = Forced(f());
                         self.get_ref()
                     }
                 }
@@ -114,7 +115,7 @@ impl<A> Future<A> {
          * function. It is not spawned into another task.
          */
 
-        Future {state: Pending(Thunk::new(f))}
+        Future {state: Pending(Box::new(f))}
     }
 }