pub struct ReusableLocalBoxFuture<T> { /* private fields */ }
Expand description
A reusable Pin<Box<dyn Future<Output = T>>
.
This type lets you replace the future stored in the box without reallocating when the size and alignment permits this.
Implementations§
Source§impl<T> ReusableLocalBoxFuture<T>
impl<T> ReusableLocalBoxFuture<T>
Sourcepub fn new<F>(future: F) -> Selfwhere
F: Future<Output = T> + 'static,
pub fn new<F>(future: F) -> Selfwhere
F: Future<Output = T> + 'static,
Create a new ReusableLocalBoxFuture<T>
containing the provided future.
Sourcepub fn set<F>(&mut self, future: F)where
F: Future<Output = T> + 'static,
pub fn set<F>(&mut self, future: F)where
F: Future<Output = T> + 'static,
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>where
F: Future<Output = T> + 'static,
pub fn try_set<F>(&mut self, future: F) -> Result<(), F>where
F: Future<Output = T> + 'static,
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 ReusableLocalBoxFuture<T>
impl<T> Debug for ReusableLocalBoxFuture<T>
Source§impl<T> Drop for ReusableLocalBoxFuture<T>
impl<T> Drop for ReusableLocalBoxFuture<T>
Source§impl<T> Future for ReusableLocalBoxFuture<T>
impl<T> Future for ReusableLocalBoxFuture<T>
impl<T> Unpin for ReusableLocalBoxFuture<T>
Auto Trait Implementations§
impl<T> Freeze for ReusableLocalBoxFuture<T>
impl<T> !RefUnwindSafe for ReusableLocalBoxFuture<T>
impl<T> !Send for ReusableLocalBoxFuture<T>
impl<T> !Sync for ReusableLocalBoxFuture<T>
impl<T> !UnwindSafe for ReusableLocalBoxFuture<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