Closed
Description
What problem does this solve or what need does it fill?
async fn
and return-position impl Trait
in trait as been stabilized in 1.75
(rust-lang/rust#115822)
What solution would you like?
Replace usage of BoxedFuture
in traits like AssetLoader
by async fn
.
bevy/crates/bevy_asset/src/loader.rs
Lines 33 to 38 in ce5bae5
async fn load<'a>(
&'a self,
reader: &'a mut Reader,
settings: &'a Self::Settings,
load_context: &'a mut LoadContext,
) -> Result<Self::Asset, Self::Error>;
What alternative(s) have you considered?
Keep using BoxedFuture
with Box::pin(async move { /* */ });
.
Current limitations
Because of the send bound problem, there is no way, yet, to add the Send
bound on the returned future.
Alternatively it's possible to use impl Future + Send
:
fn load<'a>(
&'a self,
reader: &'a mut Reader,
settings: &'a Self::Settings,
load_context: &'a mut LoadContext,
) -> impl Future<Output = Result<Self::Asset, Self::Error>> + Send + 'a;