Remove unnecessary PartialReflect
bound on DeserializeWithRegistry
(#17560)
# Objective The new `DeserializeWithRegistry` trait in 0.15 was designed to be used with reflection, and so has a `trait DeserializeWithRegistry: PartialReflect` bound. However, this bound is not actually necessary for the trait to function properly. And this `PartialReflect` bound already exists on: ```rs impl<T: PartialReflect + for<'de> DeserializeWithRegistry<'de>> FromType<T> for ReflectDeserializeWithRegistry ``` So there is no point in constraining the trait itself with this bound as well. This lets me use `DeserializeWithRegistry` with non-`Reflect` types, which I want to do to avoid making a bunch of `FooDeserializer` structs and `impl DeserializeSeed` on them. ## Solution Removes this unnecessary bound. ## Testing Trivial change, does not break compilation or `bevy_reflect` tests. ## Migration Guide `DeserializeWithRegistry` types are no longer guaranteed to be `PartialReflect` as well. If you were relying on this type bound, you should add it to your own bounds manually. ```diff - impl<T: DeserializeWithRegistry> Foo for T { .. } + impl<T: DeserializeWithRegistry + PartialReflect> Foo for T { .. } ```
This commit is contained in:
parent
b58eda01e2
commit
f232674291
@ -41,7 +41,7 @@ use serde::Deserializer;
|
||||
/// [`TypedReflectDeserializer`]: crate::serde::TypedReflectDeserializer
|
||||
/// [`ReflectDeserializer`]: crate::serde::ReflectDeserializer
|
||||
/// [via the registry]: TypeRegistry::register_type_data
|
||||
pub trait DeserializeWithRegistry<'de>: PartialReflect + Sized {
|
||||
pub trait DeserializeWithRegistry<'de>: Sized {
|
||||
fn deserialize<D>(deserializer: D, registry: &TypeRegistry) -> Result<Self, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>;
|
||||
|
Loading…
Reference in New Issue
Block a user