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 GitHub
parent 7c3131a761
commit cd0a642fa1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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: /// and scripts. In Bevy, an asset is any struct that has an unique type id, as shown below:
/// ///
/// ```rust /// ```rust
/// use bevy_reflect::TypeUuid; /// use bevy_reflect::{TypePath, TypeUuid};
/// use serde::Deserialize; /// use serde::Deserialize;
/// ///
/// #[derive(Debug, Deserialize, TypeUuid)] /// #[derive(Debug, Deserialize, TypeUuid, TypePath)]
/// #[uuid = "39cadc56-aa9c-4543-8640-a018b74b5052"] /// #[uuid = "39cadc56-aa9c-4543-8640-a018b74b5052"]
/// pub struct CustomAsset { /// pub struct CustomAsset {
/// pub value: i32, /// 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. /// See the `assets/custom_asset.rs` example in the repository for more details.