#[macro_export]
macro_rules! make_slot_wrapper {
($name:ident) => {
$crate::__make_slot_wrapper!((pub(crate)), $name);
};
}
#[macro_export]
#[doc(hidden)]
macro_rules! __make_slot_wrapper {
(($($vis:tt)*), $name:ident) => {
#[repr(transparent)]
$($vis)* struct $name<T>(Option<T>);
impl<T> $name<T> {
$($vis)* fn wrap(out: &mut Option<T>) -> &mut Self {
unsafe { &mut *(out as *mut Option<T> as *mut $name<T>) }
}
$($vis)* fn make_handle<'de>(out: &mut Option<T>) -> $crate::de::SinkHandle<'_, 'de> where $name<T>: $crate::de::Sink<'de> {
$crate::de::SinkHandle::to(Self::wrap(out))
}
}
impl<T> core::ops::Deref for $name<T> {
type Target = Option<T>;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl<T> core::ops::DerefMut for $name<T> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
};
}
macro_rules! begin_without_finish {
() => {
#[inline]
fn __private_begin(
&self,
state: &mut crate::State,
) -> Result<crate::ser::Begin<'_>, crate::Error> {
let shape = crate::ser::Serialize::container_shape(self);
Ok(crate::ser::Begin::chunk(
crate::ser::Serialize::serialize(self, state)?,
shape,
false,
))
}
};
}