pub struct ReusableBoxFuture<'a, T> { /* private fields */ }
Expand description
A reusable Pin<Box<dyn Future<Output = T> + Send + 'a>>
.
This type lets you replace the future stored in the box without reallocating when the size and alignment permits this.
Implementations§
Source§impl<'a, T> ReusableBoxFuture<'a, T>
impl<'a, T> ReusableBoxFuture<'a, T>
Sourcepub fn new<F>(future: F) -> Self
pub fn new<F>(future: F) -> Self
Create a new ReusableBoxFuture<T>
containing the provided future.
Sourcepub fn set<F>(&mut self, future: F)
pub fn set<F>(&mut self, future: F)
Replace the future currently stored in this box.
This reallocates if and only if the layout of the provided future is different from the layout of the currently stored future.
Sourcepub fn try_set<F>(&mut self, future: F) -> Result<(), F>
pub fn try_set<F>(&mut self, future: F) -> Result<(), F>
Replace the future currently stored in this box.
This function never reallocates, but returns an error if the provided future has a different size or alignment from the currently stored future.
Trait Implementations§
Source§impl<T> Debug for ReusableBoxFuture<'_, T>
impl<T> Debug for ReusableBoxFuture<'_, T>
Source§impl<T> Future for ReusableBoxFuture<'_, T>
impl<T> Future for ReusableBoxFuture<'_, T>
impl<T> Sync for ReusableBoxFuture<'_, T>
Auto Trait Implementations§
impl<'a, T> Freeze for ReusableBoxFuture<'a, T>
impl<'a, T> !RefUnwindSafe for ReusableBoxFuture<'a, T>
impl<'a, T> Send for ReusableBoxFuture<'a, T>
impl<'a, T> Unpin for ReusableBoxFuture<'a, T>
impl<'a, T> !UnwindSafe for ReusableBoxFuture<'a, T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<F> IntoFuture for Fwhere
F: Future,
impl<F> IntoFuture for Fwhere
F: Future,
Source§type IntoFuture = F
type IntoFuture = F
Source§fn into_future(self) -> <F as IntoFuture>::IntoFuture
fn into_future(self) -> <F as IntoFuture>::IntoFuture
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
Source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 16 bytes