//! Wrapper that allows changing the generic type of a PhantomData //! //! Copied from (MIT-Apache2 licences) which isn’t published yet. use rkyv::{ with::{ArchiveWith, DeserializeWith, SerializeWith}, Fallible, }; use std::marker::PhantomData; /// A wrapper that allows for changing the generic type of a `PhantomData`. pub struct CustomPhantom { _data: PhantomData<*const NT>, } impl ArchiveWith> for CustomPhantom { type Archived = PhantomData; type Resolver = (); #[inline] unsafe fn resolve_with( _: &PhantomData, _: usize, _: Self::Resolver, _: *mut Self::Archived, ) { } } impl SerializeWith, S> for CustomPhantom { #[inline] fn serialize_with(_: &PhantomData, _: &mut S) -> Result { Ok(()) } } impl DeserializeWith, PhantomData, D> for CustomPhantom { #[inline] fn deserialize_with(_: &PhantomData, _: &mut D) -> Result, D::Error> { Ok(PhantomData) } }