diff options
| author | Huon Wilson <dbau.pp+github@gmail.com> | 2015-02-13 22:58:37 +1100 |
|---|---|---|
| committer | Huon Wilson <dbau.pp+github@gmail.com> | 2015-02-18 08:19:21 +1100 |
| commit | d7b5bc3c2f673ac3edd818cb7bd42555c2cbc2a2 (patch) | |
| tree | 9fc5d0740225f18a41e9dda8ef5bfbc132a858c2 /src/libstd/thunk.rs | |
| parent | cae969e2a755bd7e8ec22758a8a02146ddb599a4 (diff) | |
| download | rust-d7b5bc3c2f673ac3edd818cb7bd42555c2cbc2a2.tar.gz rust-d7b5bc3c2f673ac3edd818cb7bd42555c2cbc2a2.zip | |
Update the libraries to reflect Send loosing the 'static bound.
In most places this preserves the current API by adding an explicit `'static` bound. Notably absent are some impls like `unsafe impl<T: Send> Send for Foo<T>` and the `std::thread` module. It is likely that it will be possible to remove these after auditing the code to ensure restricted lifetimes are safe. More progress on #22251.
Diffstat (limited to 'src/libstd/thunk.rs')
| -rw-r--r-- | src/libstd/thunk.rs | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/libstd/thunk.rs b/src/libstd/thunk.rs index 0831242f954..1412dbd70b9 100644 --- a/src/libstd/thunk.rs +++ b/src/libstd/thunk.rs @@ -16,21 +16,24 @@ use alloc::boxed::Box; use core::marker::Send; use core::ops::FnOnce; -pub struct Thunk<A=(),R=()> { - invoke: Box<Invoke<A,R>+Send> +pub struct Thunk<'a, A=(),R=()> { + #[cfg(stage0)] // // SNAP ac134f7 remove after stage0 + invoke: Box<Invoke<A,R>+Send>, + #[cfg(not(stage0))] + invoke: Box<Invoke<A,R>+Send + 'a>, } -impl<R> Thunk<(),R> { - pub fn new<F>(func: F) -> Thunk<(),R> - where F : FnOnce() -> R, F : Send +impl<'a, R> Thunk<'a,(),R> { + pub fn new<F>(func: F) -> Thunk<'a,(),R> + where F : FnOnce() -> R, F : Send + 'a { Thunk::with_arg(move|()| func()) } } -impl<A,R> Thunk<A,R> { - pub fn with_arg<F>(func: F) -> Thunk<A,R> - where F : FnOnce(A) -> R, F : Send +impl<'a,A,R> Thunk<'a,A,R> { + pub fn with_arg<F>(func: F) -> Thunk<'a,A,R> + where F : FnOnce(A) -> R, F : Send + 'a { Thunk { invoke: box func |
