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.
This commit is contained in:
Tristan Guichaoua 2023-07-11 23:24:43 +02:00 committed by Carter Anderson
parent 25c64ec7cf
commit d5f6d92344

View file

@ -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.