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
Mutably borrows from an owned value. Read more
Source§impl<F> IntoFuture for Fwhere
F: Future,
impl<F> IntoFuture for Fwhere
F: Future,
Source§type IntoFuture = F
type IntoFuture = F
Which kind of future are we turning this into?
Source§fn into_future(self) -> <F as IntoFuture>::IntoFuture
fn into_future(self) -> <F as IntoFuture>::IntoFuture
Creates a future from a value. Read more