Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Reflect for PhantomData #15313

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions crates/bevy_reflect/src/impls/std.rs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, can we add a serialization test for PhantomData in the serde module? Whether or not we're allowing this type to be serialized, we should ensure any type containing it can be deserialized and FromReflect-ed.

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use crate::{
TypeRegistration, TypeRegistry, Typed, ValueInfo,
};
use bevy_reflect_derive::{impl_reflect, impl_reflect_value};
use core::marker::PhantomData;
use std::fmt;
use std::{
any::Any,
Expand Down Expand Up @@ -1484,6 +1485,11 @@ impl_reflect! {
}
}

impl_reflect! {
BenjaminBrienen marked this conversation as resolved.
Show resolved Hide resolved
#[type_path = "core::marker"]
struct PhantomData<T: ?Sized>;
}

impl<T: TypePath + ?Sized> TypePath for &'static T {
fn type_path() -> &'static str {
static CELL: GenericTypePathCell = GenericTypePathCell::new();
Expand Down