Struct send_wrapper::SendWrapper
source · [−]pub struct SendWrapper<T> { /* private fields */ }
Expand description
A wrapper which allows you to move around non-Send
-types between threads, as long as you access the contained
value only from within the original thread and make sure that it is dropped from within the original thread.
Implementations
sourceimpl<T> SendWrapper<T>
impl<T> SendWrapper<T>
sourcepub fn new(data: T) -> SendWrapper<T>ⓘNotable traits for SendWrapper<F>impl<F: Future> Future for SendWrapper<F> type Output = F::Output;
pub fn new(data: T) -> SendWrapper<T>ⓘNotable traits for SendWrapper<F>impl<F: Future> Future for SendWrapper<F> type Output = F::Output;
Create a SendWrapper<T>
wrapper around a value of type T
.
The wrapper takes ownership of the value.
Trait Implementations
sourceimpl<T: Clone> Clone for SendWrapper<T>
impl<T: Clone> Clone for SendWrapper<T>
sourceimpl<T: Debug> Debug for SendWrapper<T>
impl<T: Debug> Debug for SendWrapper<T>
sourceimpl<T> Deref for SendWrapper<T>
impl<T> Deref for SendWrapper<T>
sourceimpl<T> DerefMut for SendWrapper<T>
impl<T> DerefMut for SendWrapper<T>
sourceimpl<T> Drop for SendWrapper<T>
impl<T> Drop for SendWrapper<T>
sourcefn drop(&mut self)
fn drop(&mut self)
Drops the contained value.
Panics
Dropping panics if it is done from a different thread than the one the SendWrapper<T>
instance has been
created with.
Exceptions:
- There is no extra panic if the thread is already panicking/unwinding. This is because otherwise there would be double panics (usually resulting in an abort) when dereferencing from a wrong thread.
- If
T
has a trivial drop (needs_drop::<T>()
is false) then this method never panics.
sourceimpl<F: Future> Future for SendWrapper<F>
Available on crate feature futures
only.
impl<F: Future> Future for SendWrapper<F>
Available on crate feature
futures
only.sourceimpl<S: Stream> Stream for SendWrapper<S>
Available on crate feature futures
only.
impl<S: Stream> Stream for SendWrapper<S>
Available on crate feature
futures
only.impl<T> Send for SendWrapper<T>
impl<T> Sync for SendWrapper<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for SendWrapper<T> where
T: RefUnwindSafe,
impl<T> Unpin for SendWrapper<T> where
T: Unpin,
impl<T> UnwindSafe for SendWrapper<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<F> IntoFuture for F where
F: Future,
impl<F> IntoFuture for F where
F: Future,
type Output = <F as Future>::Output
type Output = <F as Future>::Output
🔬 This is a nightly-only experimental API. (
into_future
)The output that the future will produce on completion.
type IntoFuture = F
type IntoFuture = F
🔬 This is a nightly-only experimental API. (
into_future
)Which kind of future are we turning this into?
sourcefn into_future(self) -> <F as IntoFuture>::IntoFuture
fn into_future(self) -> <F as IntoFuture>::IntoFuture
🔬 This is a nightly-only experimental API. (
into_future
)Creates a future from a value.