From 5b0f40f3f1f916bd41234e9d12fd82fa3335b3f1 Mon Sep 17 00:00:00 2001 From: Waridley Date: Wed, 9 Jun 2021 18:32:18 +0000 Subject: [PATCH] Document FromType trait (#2323) # Objective Prevent future unnecessary mental effort spent figuring out why this trait exists and how to resolve the `TODO`. ## Solution I happened to notice this trait being used when expanding the `#[derive(Reflect)]` macro in my own crate to figure out how it worked, and noticed that there was a `TODO` comment on it because it is only used in the derive macro and thus appeared to be unused. I figured I should document my findings to prevent someone else from finding them out the hard way in the future :laughing: Co-authored-by: Waridley --- crates/bevy_reflect/src/type_registry.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/bevy_reflect/src/type_registry.rs b/crates/bevy_reflect/src/type_registry.rs index 91f888e35dc9e..0a4394516dd3b 100644 --- a/crates/bevy_reflect/src/type_registry.rs +++ b/crates/bevy_reflect/src/type_registry.rs @@ -219,8 +219,10 @@ where } } -// TODO: Dead code -// This trait seems to be unused apart from in implementations of this trait +/// Trait used to generate `TypeData` for trait reflection. +/// +/// This is used by the `#[derive(Reflect)]` macro to generate an implementation of [TypeData] +/// to pass to [TypeRegistration::insert]. pub trait FromType { fn from_type() -> Self; }