diff --git a/crates/bevy_asset/src/asset_server.rs b/crates/bevy_asset/src/asset_server.rs index 9be1400b0575ea..12cfec7bf1fe9c 100644 --- a/crates/bevy_asset/src/asset_server.rs +++ b/crates/bevy_asset/src/asset_server.rs @@ -518,8 +518,8 @@ impl AssetServer { transform, }) => { if let Some(original) = assets.get(from) { - // `transform` can fail if it's result is not the expected type - // this should happen as public API to reach this point is stronly typed + // `transform` can fail if its result is not the expected type + // this should not happen as public API to reach this point is stronly typed // traits are only used in flight for communication if let Ok(new) = transform(original) { assets.set(to, *new); diff --git a/crates/bevy_asset/src/loader.rs b/crates/bevy_asset/src/loader.rs index a1fe00857e224f..97c4887006ca77 100644 --- a/crates/bevy_asset/src/loader.rs +++ b/crates/bevy_asset/src/loader.rs @@ -202,7 +202,14 @@ impl AssetLifecycle for AssetLifecycleChannel { .send(AssetLifecycleEvent::CreateNewFrom { from, to, - transform: Box::new(|asset: &T| transform(asset).downcast::().map_err(|_| ())), + transform: Box::new(|asset: &T| { + transform(asset) + .downcast::() + // `downcast` can fail if `transform` result is not the expected type + // this should not happen as public API to reach this point is stronly typed + // traits are only used in flight for communication + .map_err(|_| ()) + }), }) .unwrap(); }