From fbfd8befb77eee9f6082174258049121e3f4a8d2 Mon Sep 17 00:00:00 2001 From: Frizi Date: Wed, 26 May 2021 00:32:36 +0200 Subject: [PATCH] add doc comment about newtype component --- crates/bevy_ecs/src/component/mod.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/bevy_ecs/src/component/mod.rs b/crates/bevy_ecs/src/component/mod.rs index 3267461fe9a42e..f773394bd4c2d1 100644 --- a/crates/bevy_ecs/src/component/mod.rs +++ b/crates/bevy_ecs/src/component/mod.rs @@ -16,6 +16,13 @@ use thiserror::Error; /// /// Any type that is `Send + Sync + 'static` can implement `Component` using `#[derive(Component)]`. /// +/// In order to use foreign types as components, wrap them using a newtype pattern. +/// ``` +/// # use bevy_ecs::component::Component; +/// use std::time::Duration; +/// #[derive(Component)] +/// struct Cooldown(Duration); +/// ``` /// Components are added with new entities using [`Commands::spawn`](crate::system::Commands::spawn), /// or to existing entities with [`EntityCommands::insert`](crate::system::EntityCommands::insert), /// or their [`World`](crate::world::World) equivalents.