try_make

Function try_make 

Source
pub fn try_make<G>(
    val: G::Input,
    getter: G,
) -> Result<(Pin<Box<impl Future<Output = G::Output>>>, G::Aux), (G::Input, G::Error)>
where G: TryGetFut,
Expand description

Try to encapsulate a borrowed-future along with it’s owner.

This function takes the owner by value and a functor-like TryGetFut, which when invoked will return a borrowed-future.

In the case that functor returns an error, this function will return that error along with the owner. When the functor return a borrowed-future, this function returns a future which has taken ownership of the owner, and will .await the borrowed-future when polled. Auxiliary data returned by the functor is also returned in this case.

Callers may wish to use crate::try_get to quickly construct this functor for cases which don’t require capturing, but any type which implements TryGetFut will work.