diff --git a/merde/src/lib.rs b/merde/src/lib.rs index f7d53e8..9e2e8fd 100644 --- a/merde/src/lib.rs +++ b/merde/src/lib.rs @@ -100,8 +100,7 @@ macro_rules! impl_deserialize { Ok($struct_name { $($field: { if $field.is_none() { - let __field_type_name = std::any::type_name_of_val(&$field); - let __slot = $crate::FieldSlot::new(&mut $field, __field_type_name); + let __slot = $crate::FieldSlot::new(&mut $field); __opinions.default_field_value(stringify!($field), __slot); } $crate::Deserialize::from_option($field, stringify!($field).into())? @@ -163,8 +162,7 @@ macro_rules! impl_deserialize { Ok($struct_name { $($field: { if $field.is_none() { - let __field_type_name = std::any::type_name_of_val(&$field); - let __slot = $crate::FieldSlot::new(&mut $field, __field_type_name); + let __slot = $crate::FieldSlot::new(&mut $field); __opinions.default_field_value(stringify!($field), __slot); } $crate::Deserialize::from_option($field, stringify!($field).into())? diff --git a/merde_core/src/deserialize.rs b/merde_core/src/deserialize.rs index ec9c359..bb101cf 100644 --- a/merde_core/src/deserialize.rs +++ b/merde_core/src/deserialize.rs @@ -317,12 +317,13 @@ pub struct FieldSlot<'s, 'borrow> { impl<'s, 'borrow> FieldSlot<'s, 'borrow> { /// Construct a new `FieldSlot`, ready to be filled #[inline(always)] - pub fn new(option: &'borrow mut Option, type_name_of_slot: &'static str) -> Self { + #[doc(hidden)] + pub fn new(option: &'borrow mut Option) -> Self { Self { option: unsafe { std::mem::transmute::<*mut Option, *mut Option<()>>(option as *mut _) }, - type_name_of_option_field: type_name_of_slot, + type_name_of_option_field: std::any::type_name::>(), _phantom: PhantomData, } }