Skip to content

Commit cd0a642

Browse files
authored
doc(asset): fix asset trait example (#9105)
# Objective Fix the example code for the `Asset` trait. ## Solution Add `TypePath` trait on `CustomAsset`. Add a static check.
1 parent 7c3131a commit cd0a642

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

crates/bevy_asset/src/loader.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,16 @@ pub trait AssetLoader: Send + Sync + 'static {
3434
/// and scripts. In Bevy, an asset is any struct that has an unique type id, as shown below:
3535
///
3636
/// ```rust
37-
/// use bevy_reflect::TypeUuid;
37+
/// use bevy_reflect::{TypePath, TypeUuid};
3838
/// use serde::Deserialize;
3939
///
40-
/// #[derive(Debug, Deserialize, TypeUuid)]
40+
/// #[derive(Debug, Deserialize, TypeUuid, TypePath)]
4141
/// #[uuid = "39cadc56-aa9c-4543-8640-a018b74b5052"]
4242
/// pub struct CustomAsset {
4343
/// pub value: i32,
4444
/// }
45+
/// # fn is_asset<T: bevy_asset::Asset>() {}
46+
/// # is_asset::<CustomAsset>();
4547
/// ```
4648
///
4749
/// See the `assets/custom_asset.rs` example in the repository for more details.

0 commit comments

Comments
 (0)