#[macro_export]
macro_rules! z_delegate_structural_with {
(
impl $impl_params:tt $self:ty
where $where_clause:tt
self_ident=$this:ident;
delegating_to_type=$delegating_to_type:ty;
field_name_param=( $fname_var:ident : $fname_ty:ident );
GetField $get_field_closure:block
$(
unsafe 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::z_delegate_structural_with!{
inner-structural;
impl $impl_params $self
where $where_clause
self_ident=$this;
delegating_to_type=$delegating_to_type;
field_name_param=( $fname_var : $fname_ty );
GetField $get_field_closure
}
$crate::z_delegate_structural_with!{
inner;
impl $impl_params $self
where $where_clause
self_ident=$this;
delegating_to_type=$delegating_to_type;
field_name_param=( $fname_var : $fname_ty );
GetField $get_field_closure
}
$(
$crate::z_delegate_structural_with!{
inner;
impl $impl_params $self
where $where_clause
where[ $( $($mut_where_clause)* )? ]
self_ident=$this;
delegating_to_type=$delegating_to_type;
field_name_param=( $fname_var : $fname_ty );
GetField $get_field_closure
unsafe GetFieldMut $unsafe_get_field_mut_closure
as_delegating_raw $as_field_mutref_closure
}
)?
$(
$crate::z_delegate_structural_with!{
inner;
impl $impl_params $self
where $where_clause
where [ $( $($into_where_clause)* )? ]
self_ident=$this;
delegating_to_type=$delegating_to_type;
field_name_param=( $fname_var : $fname_ty );
IntoField $into_field_closure
}
)?
);
(
inner-structural;
impl[$($impl_params:tt)*] $self:ty
where [$($where_clause:tt)*]
self_ident=$this:ident;
delegating_to_type=$delegating_to_type:ty;
field_name_param=( $fname_var:ident : $fname_ty:ident );
GetField $get_field_closure:block
)=>{
impl<$($impl_params)*> $crate::Structural for $self
where
$delegating_to_type:$crate::Structural,
$($where_clause)*
{
const FIELDS:&'static[$crate::structural_trait::FieldInfo]=
<$delegating_to_type as $crate::Structural>::FIELDS;
}
impl<$($impl_params)*> $crate::StructuralDyn for $self
where
$delegating_to_type:$crate::StructuralDyn,
$($where_clause)*
{
fn fields_info(&self)->&'static[$crate::structural_trait::FieldInfo]{
let $this=self;
let field:&$delegating_to_type=$get_field_closure;
$crate::StructuralDyn::fields_info(field)
}
}
};
(inner;
impl [$($($impl_params:tt)+)?] $self:ty
where [$($where_clause:tt)*]
self_ident=$this:ident;
delegating_to_type=$delegating_to_type:ty;
field_name_param=( $fname_var:ident : $fname_ty:ident );
GetField $get_field_closure:block
)=>{
impl<$($($impl_params)* )?__FieldName>
$crate::GetField<__FieldName>
for $self
where
$delegating_to_type:$crate::GetField<__FieldName>,
$($where_clause)*
{
type Ty=$crate::GetFieldType<$delegating_to_type,__FieldName>;
fn get_field_(&self)->&Self::Ty{
let $this=self;
let field:&$delegating_to_type=$get_field_closure;
$crate::GetField::<__FieldName>::get_field_(field)
}
}
};
(inner;
impl [$($($impl_params:tt)+)?] $self:ty
where [$($where_clause:tt)*]
where [$($mut_where_clause:tt)*]
self_ident=$this:ident;
delegating_to_type=$delegating_to_type:ty;
field_name_param=( $fname_var:ident : $fname_ty:ident );
GetField $get_field_closure:block
unsafe GetFieldMut $unsafe_get_field_mut_closure:block
as_delegating_raw $as_field_mutref_closure:block
)=>{
unsafe impl<$( $($impl_params)* )?__FieldName>
$crate::GetFieldMut<__FieldName>
for $self
where
$delegating_to_type:$crate::GetFieldMut<__FieldName>,
$($mut_where_clause)*
$($where_clause)*
{
fn get_field_mut_(&mut self)->&mut Self::Ty{
let $this=self;
let field:&mut $delegating_to_type=$unsafe_get_field_mut_closure;
<$delegating_to_type as $crate::GetFieldMut<__FieldName>>::get_field_mut_(field)
}
unsafe fn get_field_raw_mut(
$this:*mut (),
$fname_var:$crate::pmr::PhantomData<__FieldName>
)->*mut Self::Ty
where
Self:Sized
{
let $this=$this as *mut Self;
let $this:*mut $delegating_to_type=
$as_field_mutref_closure;
<$delegating_to_type>::get_field_raw_mut( $this as *mut (),$fname_var )
}
fn get_field_raw_mut_func(
&self
)->$crate::field_traits::GetFieldMutRefFn<__FieldName,Self::Ty>{
<Self as $crate::GetFieldMut<__FieldName>>::get_field_raw_mut
}
}
};
(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;
field_name_param=( $fname_var:ident : $fname_ty:ident );
IntoField $into_field_closure:block
)=>{
impl<$( $($impl_params)* )?__FieldName>
$crate::IntoField<__FieldName>
for $self
where
$delegating_to_type:$crate::IntoField<__FieldName>,
$($into_where_clause)*
$($where_clause)*
{
fn into_field_(self)->Self::Ty{
let $this=self;
let field:$delegating_to_type=$into_field_closure;
$crate::IntoField::<__FieldName>::into_field_(field)
}
$crate::z_impl_box_into_field_method!{__FieldName}
}
};
}