Skip to content

Commit

Permalink
doc(asset): fix asset trait example (#9105)
Browse files Browse the repository at this point in the history
# Objective

Fix the example code for the `Asset` trait.

## Solution

Add `TypePath` trait on `CustomAsset`.
Add a static check.
  • Loading branch information
tguichaoua authored Jul 11, 2023
1 parent 7c3131a commit cd0a642
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions crates/bevy_asset/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@ pub trait AssetLoader: Send + Sync + 'static {
/// and scripts. In Bevy, an asset is any struct that has an unique type id, as shown below:
///
/// ```rust
/// use bevy_reflect::TypeUuid;
/// use bevy_reflect::{TypePath, TypeUuid};
/// use serde::Deserialize;
///
/// #[derive(Debug, Deserialize, TypeUuid)]
/// #[derive(Debug, Deserialize, TypeUuid, TypePath)]
/// #[uuid = "39cadc56-aa9c-4543-8640-a018b74b5052"]
/// pub struct CustomAsset {
/// pub value: i32,
/// }
/// # fn is_asset<T: bevy_asset::Asset>() {}
/// # is_asset::<CustomAsset>();
/// ```
///
/// See the `assets/custom_asset.rs` example in the repository for more details.
Expand Down

0 comments on commit cd0a642

Please sign in to comment.