Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bevyengine
GitHub Repository: bevyengine/bevy
Path: blob/main/crates/bevy_reflect/src/reflectable.rs
6598 views
1
use crate::{GetTypeRegistration, Reflect, TypePath, Typed};
2
3
/// A catch-all trait that is bound by the core reflection traits,
4
/// useful to simplify reflection-based generic type bounds.
5
///
6
/// You do _not_ need to implement this trait manually.
7
/// It is automatically implemented for all types that implement its supertraits.
8
/// And these supertraits are all automatically derived with the [`Reflect` derive macro].
9
///
10
/// This should namely be used to bound generic arguments to the necessary traits for reflection.
11
/// Doing this has the added benefit of reducing migration costs, as a change to the required traits
12
/// is automatically handled by this trait.
13
///
14
/// For now, the supertraits of this trait includes:
15
/// * [`Reflect`]
16
/// * [`GetTypeRegistration`]
17
/// * [`Typed`]
18
/// * [`TypePath`]
19
///
20
/// ## Example
21
///
22
/// ```
23
/// # use bevy_reflect::{Reflect, Reflectable};
24
/// #[derive(Reflect)]
25
/// struct MyStruct<T: Reflectable> {
26
/// value: T
27
/// }
28
/// ```
29
///
30
/// [`Reflect` derive macro]: bevy_reflect_derive::Reflect
31
pub trait Reflectable: Reflect + GetTypeRegistration + Typed + TypePath {}
32
33
impl<T: Reflect + GetTypeRegistration + Typed + TypePath> Reflectable for T {}
34
35