Skip to content

Commit

Permalink
Document FromType trait (bevyengine#2323)
Browse files Browse the repository at this point in the history
# 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 😆 

Co-authored-by: Waridley <Waridley64@gmail.com>
  • Loading branch information
Waridley and Waridley committed Jun 9, 2021
1 parent a40ec1c commit 5b0f40f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions crates/bevy_reflect/src/type_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> {
fn from_type() -> Self;
}
Expand Down

0 comments on commit 5b0f40f

Please sign in to comment.