#[macro_export]
macro_rules! unsafe_delegate_structural_with {
(
$( #[doc=$doc:expr] )*
impl $impl_params:tt $self:ty
where $where_clause:tt
self_ident=$this:ident;
$( specialization_params($($raw_mut_impl:tt)*); )?
delegating_to_type=$delegating_to_type:ty;
$($rest:tt)*
) => (
$crate::unsafe_delegate_structural_with_inner!{
$( #[doc=$doc] )*
impl $impl_params $self
where $where_clause
self_ident=$this;
specialization_params( $( $($raw_mut_impl)* )? );
delegating_to_type=$delegating_to_type;
$($rest)*
}
)
}
#[macro_export]
#[doc(hidden)]
macro_rules! unsafe_delegate_structural_with_inner {
(
$( #[doc=$doc:expr] )*
impl $impl_params:tt $self:ty
where $where_clause:tt
self_ident=$this:ident;
specialization_params $raw_mut_impl:tt;
delegating_to_type=$delegating_to_type:ty;
GetField $get_field_closure:block
$(
GetFieldMut
$( where[ $($mut_where_clause:tt)* ] )?
$unsafe_get_field_mut_closure:block
as_delegating_raw $as_field_mutref_closure:block
)?
$(
IntoField
$( where[ $($into_where_clause:tt)* ] )?
$into_field_closure:block
)?
) => (
$crate::unsafe_delegate_structural_with_inner!{
inner-structural;
$( #[doc=$doc] )*
impl $impl_params $self
where $where_clause
self_ident=$this;
delegating_to_type=$delegating_to_type;
GetField $get_field_closure
}
$crate::unsafe_delegate_structural_with_inner!{
inner;
impl $impl_params $self
where $where_clause
self_ident=$this;
delegating_to_type=$delegating_to_type;
GetField $get_field_closure
}
$(
$crate::unsafe_delegate_structural_with_inner!{
inner;
impl $impl_params $self
where $where_clause
where[ $( $($mut_where_clause)* )? ]
self_ident=$this;
specialization_params $raw_mut_impl;
delegating_to_type=$delegating_to_type;
GetFieldMut $unsafe_get_field_mut_closure
as_delegating_raw $as_field_mutref_closure
}
)?
$(
$crate::unsafe_delegate_structural_with_inner!{
inner;
impl $impl_params $self
where $where_clause
where [ $( $($into_where_clause)* )? ]
self_ident=$this;
delegating_to_type=$delegating_to_type;
IntoField $into_field_closure
}
)?
);
(
inner-structural;
$( #[doc=$doc:expr] )*
impl[$($impl_params:tt)*] $self:ty
where [$($where_clause:tt)*]
self_ident=$this:ident;
delegating_to_type=$delegating_to_type:ty;
GetField $get_field_closure:block
)=>{
$( #[doc=$doc] )*
impl<$($impl_params)*> $crate::Structural for $self
where
$delegating_to_type: $crate::Structural,
$($where_clause)*
{}
};
(inner;
impl [$($impl_params:tt)*] $self:ty
where [$($where_clause:tt)*]
self_ident=$this:ident;
delegating_to_type=$delegating_to_type:ty;
GetField $get_field_closure:block
)=>{
unsafe impl<$($impl_params)* __V>
$crate::pmr::IsVariant<$crate::TStr<__V>>
for $self
where
$delegating_to_type: $crate::pmr::IsVariant<$crate::TStr<__V>>,
$($where_clause)*
{
fn is_variant_(&self,name:$crate::TStr<__V>)->bool{
let $this=self;
let field:&$delegating_to_type=$get_field_closure;
$crate::pmr::IsVariant::is_variant_(field,name)
}
}
unsafe impl<$($impl_params)*> $crate::pmr::VariantCount for $self
where
$delegating_to_type: $crate::pmr::VariantCount,
$($where_clause)*
{
type Count=$crate::pmr::VariantCountOut<$delegating_to_type>;
}
unsafe impl<$($impl_params)* __V,__F,__Ty>
$crate::GetVariantField<$crate::TStr<__V>,__F>
for $self
where
$delegating_to_type:
$crate::GetVariantField<$crate::TStr<__V>,__F,Ty=__Ty>,
$($where_clause)*
{
#[inline(always)]
fn get_vfield_(
&self,
vname: $crate::TStr<__V>,
fname: __F,
) -> Option<&$crate::GetVariantFieldType<
$delegating_to_type,
$crate::TStr<__V>,
__F
>>
{
let $this=self;
let field:&$delegating_to_type=$get_field_closure;
$crate::GetVariantField::get_vfield_(field,vname,fname)
}
}
impl<$($impl_params)* NP,__Ty> $crate::FieldType<NP> for $self
where
$delegating_to_type: $crate::FieldType<NP,Ty=__Ty>,
$($where_clause)*
{
type Ty=$crate::GetFieldType<$delegating_to_type, NP>;
}
impl<$($impl_params)* __F,__Ty>
$crate::GetField< __F>
for $self
where
$delegating_to_type: $crate::GetField<__F,Ty=__Ty>,
$($where_clause)*
{
#[inline(always)]
fn get_field_(
&self,
fname: __F,
)->&__Ty{
let $this=self;
let field:&$delegating_to_type=$get_field_closure;
$crate::GetField::get_field_(field,fname)
}
}
};
(inner;
impl [$($impl_params:tt)*] $self:ty
where [$($where_clause:tt)*]
where [$($mut_where_clause:tt)*]
self_ident=$this:ident;
specialization_params($($raw_mut_impl:tt)*);
delegating_to_type=$delegating_to_type:ty;
GetFieldMut $unsafe_get_field_mut_closure:block
as_delegating_raw $as_field_mutref_closure:block
)=>{
$crate::unsafe_delegate_structural_with_inner!{
inner-mut-0;
(
impl [$($impl_params)*] $self
where [$($where_clause)*]
where [$($mut_where_clause)*]
self_ident=$this;
specialization_params($($raw_mut_impl)*);
delegating_to_type=$delegating_to_type;
GetFieldMut $unsafe_get_field_mut_closure
as_delegating_raw $as_field_mutref_closure
)
}
};
(inner-mut-0; $inner_mut_stuff:tt )=>{
$crate::unsafe_delegate_structural_with_inner!{
inner-mut-1;
$inner_mut_stuff
$inner_mut_stuff
}
};
(inner-mut-1;
(
impl [$($impl_params:tt)*] $self:ty
where [$($where_clause:tt)*]
where [$($mut_where_clause:tt)*]
self_ident=$this:ident;
specialization_params( $(Sized)? );
delegating_to_type=$delegating_to_type:ty;
GetFieldMut $unsafe_get_field_mut_closure:block
as_delegating_raw $as_field_mutref_closure:block
)
$inner_mut_stuff:tt
)=>{
$crate::unsafe_delegate_structural_with_inner!{
inner-mut-2;
$inner_mut_stuff
struct_fn(
#[inline(always)]
unsafe fn get_field_raw_mut(
$this:*mut (),
fname: __F,
)->*mut __Ty
where
Self:Sized
{
let $this=$this as *mut Self;
let $this:*mut $delegating_to_type=
$as_field_mutref_closure;
<$delegating_to_type as
$crate::GetFieldMut<__F>
>::get_field_raw_mut( $this as *mut (),fname )
}
)
enum_fn(
#[inline(always)]
unsafe fn get_vfield_raw_mut_(
$this: *mut (),
vname: $crate::TStr<__V>,
fname: __F,
) -> Option<$crate::pmr::NonNull<__Ty>>
where
Self: Sized
{
let $this=$this as *mut Self;
let $this:*mut $delegating_to_type=
$as_field_mutref_closure;
<$delegating_to_type as
$crate::GetVariantFieldMut<$crate::TStr<__V>,__F>
>::get_vfield_raw_mut_( $this as *mut (),vname,fname)
}
)
impl()
}
};
(inner-mut-1;
(
impl [$($impl_params:tt)*] $self:ty
where [$($where_clause:tt)*]
where [$($mut_where_clause:tt)*]
self_ident=$this:ident;
specialization_params( ?Sized );
delegating_to_type=$delegating_to_type:ty;
GetFieldMut $unsafe_get_field_mut_closure:block
as_delegating_raw $as_field_mutref_closure:block
)
$inner_mut_stuff:tt
)=>{
$crate::unsafe_delegate_structural_with_inner!{
inner-mut-2;
$inner_mut_stuff
struct_fn(
#[inline(always)]
unsafe fn get_field_raw_mut(
$this:*mut (),
fname: __F,
)->*mut __Ty
where
Self:Sized
{
let $this=$this as *mut Self;
let $this:*mut $delegating_to_type=
$as_field_mutref_closure;
let func=<
$delegating_to_type as
$crate::GetFieldMut<__F>
>::get_field_raw_mut_fn(&*$this);
func( $this as *mut (),fname )
}
)
enum_fn(
#[inline(always)]
unsafe fn get_vfield_raw_mut_(
$this: *mut (),
vname: $crate::TStr<__V>,
fname: __F,
) -> Option<$crate::pmr::NonNull<__Ty>>
where
Self: Sized
{
let $this=$this as *mut Self;
let $this:*mut $delegating_to_type=
$as_field_mutref_closure;
let func=<
$delegating_to_type as
$crate::GetVariantFieldMut<$crate::TStr<__V>,__F>
>::get_vfield_raw_mut_fn(&*$this);
func( $this as *mut (),vname,fname )
}
)
impl()
}
};
(inner-mut-1;
(
impl [$($impl_params:tt)*] $self:ty
where [$($where_clause:tt)*]
where [$($mut_where_clause:tt)*]
self_ident=$this:ident;
specialization_params( specialize_cfg( $($specialize_cfg:tt)* ) );
delegating_to_type=$delegating_to_type:ty;
GetFieldMut $unsafe_get_field_mut_closure:block
as_delegating_raw $as_field_mutref_closure:block
)
$inner_mut_stuff:tt
)=>{
$crate::unsafe_delegate_structural_with_inner!{
inner-mut-2;
$inner_mut_stuff
struct_fn(
#[inline(always)]
unsafe fn get_field_raw_mut(
$this:*mut (),
fname: __F,
)->*mut __Ty
where
Self:Sized
{
<Self as
$crate::pmr::SpecGetFieldMut<__F>
>::get_field_raw_mut_inner(
$this,
fname,
)
}
)
enum_fn(
#[inline(always)]
unsafe fn get_vfield_raw_mut_(
$this: *mut (),
vname: $crate::TStr<__V>,
fname: __F,
) -> Option<$crate::pmr::NonNull<__Ty>>
where
Self: Sized
{
<Self as
$crate::pmr::SpecGetVariantFieldMut<$crate::TStr<__V>,__F>
>::get_vfield_raw_mut_inner(
$this,
vname,
fname,
)
}
)
impl(
unsafe impl<$($impl_params)* __F,__Ty>
$crate::pmr::SpecGetFieldMut< __F>
for $self
where
$delegating_to_type: $crate::GetFieldMut<__F,Ty=__Ty>,
$($mut_where_clause)*
$($where_clause)*
{
$crate::default_if!{
#[inline(always)]
cfg(all($($specialize_cfg)*))
unsafe fn get_field_raw_mut_inner(
$this:*mut (),
fname: __F,
)->*mut __Ty
where
Self:Sized
{
let $this=$this as *mut Self;
let $this:*mut $delegating_to_type=
$as_field_mutref_closure;
let func=<
$delegating_to_type as
$crate::GetFieldMut<__F>
>::get_field_raw_mut_fn(&*$this);
func( $this as *mut (),fname )
}
}
}
#[cfg(all($($specialize_cfg)*))]
unsafe impl<$($impl_params)* __F,__Ty>
$crate::pmr::SpecGetFieldMut< __F>
for $self
where
$delegating_to_type:
Sized +
$crate::GetFieldMut<__F,Ty=__Ty>,
$($mut_where_clause)*
$($where_clause)*
{
unsafe fn get_field_raw_mut_inner(
$this:*mut (),
fname: __F,
)->*mut __Ty
where
Self:Sized
{
let $this=$this as *mut Self;
let $this:*mut $delegating_to_type=
$as_field_mutref_closure;
<$delegating_to_type as
$crate::GetFieldMut<__F>
>::get_field_raw_mut( $this as *mut (),fname )
}
}
unsafe impl<$($impl_params)* __V,__F,__Ty>
$crate::pmr::SpecGetVariantFieldMut< $crate::TStr<__V>,__F>
for $self
where
$delegating_to_type:
$crate::GetVariantFieldMut<$crate::TStr<__V>,__F,Ty=__Ty>,
$($mut_where_clause)*
$($where_clause)*
{
$crate::default_if!{
#[inline(always)]
cfg(all($($specialize_cfg)*))
unsafe fn get_vfield_raw_mut_inner(
$this:*mut (),
vname: $crate::TStr<__V>,
fname: __F,
)->Option<$crate::pmr::NonNull<
__Ty
>>
where
Self:Sized
{
let $this=$this as *mut Self;
let $this:*mut $delegating_to_type=
$as_field_mutref_closure;
let func=<
$delegating_to_type as
$crate::GetVariantFieldMut<$crate::TStr<__V>,__F>
>::get_vfield_raw_mut_fn(&*$this);
func( $this as *mut (),vname,fname )
}
}
}
#[cfg(all($($specialize_cfg)*))]
unsafe impl<$($impl_params)* __V,__F,__Ty>
$crate::pmr::SpecGetVariantFieldMut< $crate::TStr<__V>,__F>
for $self
where
$delegating_to_type:
Sized +
$crate::GetVariantFieldMut<$crate::TStr<__V>,__F,Ty=__Ty>,
$($mut_where_clause)*
$($where_clause)*
{
unsafe fn get_vfield_raw_mut_inner(
$this:*mut (),
vname: $crate::TStr<__V>,
fname: __F,
)->Option<$crate::pmr::NonNull<__Ty>>
where
Self:Sized
{
let $this=$this as *mut Self;
let $this:*mut $delegating_to_type=
$as_field_mutref_closure;
<$delegating_to_type as
$crate::GetVariantFieldMut<$crate::TStr<__V>,__F>
>::get_vfield_raw_mut_( $this as *mut (),vname,fname )
}
}
)
}
};
(inner-mut-2;
(
impl [$($impl_params:tt)*] $self:ty
where [$($where_clause:tt)*]
where [$($mut_where_clause:tt)*]
self_ident=$this:ident;
specialization_params($($raw_mut_impl:tt)*);
delegating_to_type=$delegating_to_type:ty;
GetFieldMut $unsafe_get_field_mut_closure:block
as_delegating_raw $as_field_mutref_closure:block
)
struct_fn( $($raw_ptr_fn:tt)* )
enum_fn( $($raw_enum_ptr_fn:tt)* )
impl( $($raw_ptr_impl:tt)* )
)=>{
unsafe impl<$($impl_params)* __F,__Ty>
$crate::GetFieldMut<__F>
for $self
where
$self: Sized,
$delegating_to_type:
$crate::GetFieldMut<__F,Ty=__Ty>,
$($where_clause)*
$($mut_where_clause)*
{
#[inline(always)]
fn get_field_mut_(
&mut self,
fname: __F,
)->&mut __Ty {
let $this=self;
let field:&mut $delegating_to_type=$unsafe_get_field_mut_closure;
<$delegating_to_type as
$crate::GetFieldMut<_>
>::get_field_mut_(field,fname)
}
$($raw_ptr_fn)*
#[inline(always)]
fn get_field_raw_mut_fn(
&self
)->$crate::field::GetFieldRawMutFn<
__F,
__Ty,
>{
<Self as $crate::GetFieldMut<__F>>::get_field_raw_mut
}
}
unsafe impl<$($impl_params)* __V,__F,__Ty>
$crate::GetVariantFieldMut<$crate::TStr<__V>,__F>
for $self
where
$self: Sized,
$delegating_to_type: $crate::GetVariantFieldMut<$crate::TStr<__V>,__F,Ty=__Ty>,
$($where_clause)*
$($mut_where_clause)*
{
#[inline(always)]
fn get_vfield_mut_(
&mut self,
vname: $crate::TStr<__V>,
fname: __F,
) -> Option<&mut __Ty>{
let $this=self;
let field:&mut $delegating_to_type=$unsafe_get_field_mut_closure;
<$delegating_to_type as
$crate::GetVariantFieldMut<$crate::TStr<__V>,__F>
>::get_vfield_mut_(field,vname,fname)
}
$($raw_enum_ptr_fn)*
#[inline(always)]
fn get_vfield_raw_mut_unchecked_fn(
&self
)->$crate::pmr::GetFieldRawMutFn<__F,__Ty>{
<Self as
$crate::GetVariantFieldMut<$crate::TStr<__V>,__F>
>::get_vfield_raw_mut_unchecked
}
#[inline(always)]
fn get_vfield_raw_mut_fn(
&self
)->$crate::pmr::GetVFieldRawMutFn<
$crate::TStr<__V>,
__F,
__Ty
>
{
<Self as
$crate::GetVariantFieldMut<$crate::TStr<__V>,__F>
>::get_vfield_raw_mut_
}
}
$($raw_ptr_impl)*
};
(inner;
impl [$($impl_params:tt)*] $self:ty
where [$($where_clause:tt)*]
where [$($into_where_clause:tt)*]
self_ident=$this:ident;
delegating_to_type=$delegating_to_type:ty;
IntoField $into_field_closure:block
)=>{
unsafe impl<$($impl_params)* __V,__F,__Ty>
$crate::pmr::IntoVariantField<$crate::TStr<__V>,__F>
for $self
where
$delegating_to_type:
Sized+
$crate::pmr::IntoVariantField<$crate::TStr<__V>,__F,Ty=__Ty>,
$($into_where_clause)*
$($where_clause)*
{
#[inline(always)]
fn into_vfield_(
self,
vname:$crate::TStr<__V>,
fname:__F,
)->Option<$crate::GetVariantFieldType<$delegating_to_type,$crate::TStr<__V>,__F>>{
let $this=self;
let field:$delegating_to_type=$into_field_closure;
$crate::IntoVariantField::<$crate::TStr<__V>,__F>::into_vfield_(field,vname,fname)
}
$crate::z_impl_box_into_variant_field_method!{
variant_tstr= $crate::TStr<__V>,
field_tstr= __F,
field_type= $crate::GetVariantFieldType<$delegating_to_type,$crate::TStr<__V>,__F>,
}
}
impl<$($impl_params)* __F,__Ty>
$crate::IntoField< __F>
for $self
where
$delegating_to_type:
Sized+
$crate::IntoField<__F,Ty=__Ty>,
$($into_where_clause)*
$($where_clause)*
{
#[inline(always)]
fn into_field_(
self,
fname: __F,
)->__Ty{
let $this=self;
let field:$delegating_to_type=$into_field_closure;
$crate::IntoField::<__F>::into_field_(field,fname)
}
$crate::z_impl_box_into_field_method!{
field_tstr=__F,
field_type=__Ty,
}
}
};
}