From cd0a642fa19476dd9876aa71198ee28b62e0e3f2 Mon Sep 17 00:00:00 2001 From: Tristan Guichaoua <33934311+tguichaoua@users.noreply.github.com> Date: Tue, 11 Jul 2023 23:24:43 +0200 Subject: [PATCH] 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. --- crates/bevy_asset/src/loader.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/bevy_asset/src/loader.rs b/crates/bevy_asset/src/loader.rs index a494fd0a2cc01..6853ebf228df6 100644 --- a/crates/bevy_asset/src/loader.rs +++ b/crates/bevy_asset/src/loader.rs @@ -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() {} +/// # is_asset::(); /// ``` /// /// See the `assets/custom_asset.rs` example in the repository for more details.