We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 767dc2a commit af934d0Copy full SHA for af934d0
crates/bevy_reflect/src/serde/serialize_with_registry.rs
@@ -83,8 +83,14 @@ impl ReflectSerializeWithRegistry {
83
impl<T: Reflect + SerializeWithRegistry> FromType<T> for ReflectSerializeWithRegistry {
84
fn from_type() -> Self {
85
Self {
86
- serialize: |value, registry| {
87
- let value = value.downcast_ref::<T>().unwrap();
+ serialize: |value: &dyn Reflect, registry| {
+ let value = value.downcast_ref::<T>().unwrap_or_else(|| {
88
+ panic!(
89
+ "Expected value to be of type {:?} but received {:?}",
90
+ std::any::type_name::<T>(),
91
+ value.reflect_type_path()
92
+ )
93
+ });
94
Box::new(SerializableWithRegistry { value, registry })
95
},
96
}
0 commit comments