diff options
Diffstat (limited to 'src/libstd/sync/future.rs')
| -rw-r--r-- | src/libstd/sync/future.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/libstd/sync/future.rs b/src/libstd/sync/future.rs index a230e35dac8..d60e2738808 100644 --- a/src/libstd/sync/future.rs +++ b/src/libstd/sync/future.rs @@ -38,7 +38,7 @@ use core::mem::replace; use self::FutureState::*; use sync::mpsc::{Receiver, channel}; use thunk::{Thunk}; -use thread::Thread; +use thread; /// A type encapsulating the result of a computation which may not be complete pub struct Future<A> { @@ -46,7 +46,7 @@ pub struct Future<A> { } enum FutureState<A> { - Pending(Thunk<(),A>), + Pending(Thunk<'static,(),A>), Evaluating, Forced(A) } @@ -103,7 +103,7 @@ impl<A> Future<A> { } pub fn from_fn<F>(f: F) -> Future<A> - where F : FnOnce() -> A, F : Send + where F : FnOnce() -> A, F : Send + 'static { /*! * Create a future from a function. @@ -117,7 +117,7 @@ impl<A> Future<A> { } } -impl<A:Send> Future<A> { +impl<A:Send+'static> Future<A> { pub fn from_receiver(rx: Receiver<A>) -> Future<A> { /*! * Create a future from a port @@ -132,7 +132,7 @@ impl<A:Send> Future<A> { } pub fn spawn<F>(blk: F) -> Future<A> - where F : FnOnce() -> A, F : Send + where F : FnOnce() -> A, F : Send + 'static { /*! * Create a future from a unique closure. @@ -143,7 +143,7 @@ impl<A:Send> Future<A> { let (tx, rx) = channel(); - Thread::spawn(move || { + thread::spawn(move || { // Don't panic if the other end has hung up let _ = tx.send(blk()); }); @@ -157,7 +157,7 @@ mod test { use prelude::v1::*; use sync::mpsc::channel; use sync::Future; - use thread::Thread; + use thread; #[test] fn test_from_value() { @@ -215,7 +215,7 @@ mod test { let expected = "schlorf"; let (tx, rx) = channel(); let f = Future::spawn(move|| { expected }); - let _t = Thread::spawn(move|| { + let _t = thread::spawn(move|| { let mut f = f; tx.send(f.get()).unwrap(); }); |
