From 0344bad25d04e2b6719c379bfc58fbbe851f7179 Mon Sep 17 00:00:00 2001 From: Gino Valente Date: Tue, 30 Aug 2022 21:46:30 -0700 Subject: [PATCH] Update documentation for Reflectable --- crates/bevy_reflect/src/lib.rs | 2 +- crates/bevy_reflect/src/reflect.rs | 6 ++++++ crates/bevy_reflect/src/type_info.rs | 3 +++ crates/bevy_reflect/src/type_registry.rs | 4 ++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/crates/bevy_reflect/src/lib.rs b/crates/bevy_reflect/src/lib.rs index 0fc628c8af459a..ef5d346f28cd1f 100644 --- a/crates/bevy_reflect/src/lib.rs +++ b/crates/bevy_reflect/src/lib.rs @@ -55,7 +55,7 @@ pub use type_info::*; pub use type_registry::*; pub use type_uuid::*; -/// A catch-all trait bound by the core reflection traits for easy reflection-based trait bounds. +/// A catch-all trait, bound by the core reflection traits for easy reflection-based trait bounds. /// /// You do _not_ need to implement this trait manually. /// It is automatically implemented for all types that implement its supertraits. diff --git a/crates/bevy_reflect/src/reflect.rs b/crates/bevy_reflect/src/reflect.rs index 3b3b7c274445af..2f16410642867b 100644 --- a/crates/bevy_reflect/src/reflect.rs +++ b/crates/bevy_reflect/src/reflect.rs @@ -52,6 +52,12 @@ pub enum ReflectMut<'a> { /// /// When using `#[derive(Reflect)]` with a struct or tuple struct, the suitable subtrait for that /// type (`Struct` or `TupleStruct`) is derived automatically. +/// +/// Typically, generic types will require that their generic arguments be bound by `Reflect`, among +/// other reflection traits. In these cases, it's recommended to use the [`Reflectable`] trait to +/// cover all the necessary bounds. +/// +/// [`Reflectable`]: crate::Reflectable pub trait Reflect: Any + Send + Sync { /// Returns the [type name][std::any::type_name] of the underlying type. fn type_name(&self) -> &str; diff --git a/crates/bevy_reflect/src/type_info.rs b/crates/bevy_reflect/src/type_info.rs index afbe037b7243d8..b2ef8a59aab4ee 100644 --- a/crates/bevy_reflect/src/type_info.rs +++ b/crates/bevy_reflect/src/type_info.rs @@ -8,6 +8,8 @@ use std::any::{Any, TypeId}; /// This trait is automatically implemented by the `#[derive(Reflect)]` macro /// and allows type information to be processed without an instance of that type. /// +/// As a core trait to the reflection system, it is a supertrait of [`Reflectable`]. +/// /// # Implementing /// /// While it is recommended to leave implementing this trait to the `#[derive(Reflect)]` macro, @@ -63,6 +65,7 @@ use std::any::{Any, TypeId}; /// # } /// ``` /// +/// [`Reflectable`]: crate::Reflectable /// [utility]: crate::utility pub trait Typed: Reflect { /// Returns the compile-time [info] for the underlying type. diff --git a/crates/bevy_reflect/src/type_registry.rs b/crates/bevy_reflect/src/type_registry.rs index 74865abeb0c915..67a8983436bca2 100644 --- a/crates/bevy_reflect/src/type_registry.rs +++ b/crates/bevy_reflect/src/type_registry.rs @@ -31,6 +31,10 @@ impl Debug for TypeRegistryArc { /// A trait which allows a type to generate its [`TypeRegistration`]. /// /// This trait is automatically implemented for types which derive [`Reflect`]. +/// +/// As a core trait to the reflection system, it is a supertrait of [`Reflectable`]. +/// +/// [`Reflectable`]: crate::Reflectable pub trait GetTypeRegistration { fn get_type_registration() -> TypeRegistration; }