-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Closed
Labels
A-AssetsLoad files from disk to use for things like images, models, and soundsLoad files from disk to use for things like images, models, and soundsC-FeatureA new feature, making something new possibleA new feature, making something new possible
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
fn load<'a>( | |
&'a self, | |
reader: &'a mut Reader, | |
settings: &'a Self::Settings, | |
load_context: &'a mut LoadContext, | |
) -> BoxedFuture<'a, Result<Self::Asset, Self::Error>>; |
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;
Metadata
Metadata
Assignees
Labels
A-AssetsLoad files from disk to use for things like images, models, and soundsLoad files from disk to use for things like images, models, and soundsC-FeatureA new feature, making something new possibleA new feature, making something new possible