Skip to content

Commit

Permalink
typo and add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mockersf committed Mar 16, 2021
1 parent a6c3e6d commit ab62ffd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions crates/bevy_asset/src/asset_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 8 additions & 1 deletion crates/bevy_asset/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,14 @@ impl<T: AssetDynamic> AssetLifecycle for AssetLifecycleChannel<T> {
.send(AssetLifecycleEvent::CreateNewFrom {
from,
to,
transform: Box::new(|asset: &T| transform(asset).downcast::<T>().map_err(|_| ())),
transform: Box::new(|asset: &T| {
transform(asset)
.downcast::<T>()
// `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();
}
Expand Down

0 comments on commit ab62ffd

Please sign in to comment.