konst/macros/
polymorphism_macros.rs#[doc(hidden)]
#[macro_export]
macro_rules! __priv_delegate_const_inner_fn{
(
$(skip_coerce $(@$_skip:tt@)?;)?
$(for[$($implg:tt)*])?
$(#[$attr:meta])*
pub const fn $func:ident $(<$($fnlt:lifetime),* $(,)?>)?(
$($idents:ident)* : $l_ty:ty,
$rhs:ident: $r_ty:ty $(,)*
) -> $ret:ty $block:block
)=>{
$(#[$attr])*
pub const fn $func<$($($fnlt,)*)? $($($implg)*)?>(
$crate::__priv_get_pati_ident!($($idents)*): $l_ty,
$rhs: $r_ty,
) -> $ret $block
}
}
#[cfg(feature = "cmp")]
#[doc(hidden)]
#[macro_export]
macro_rules! __priv_delegate_const_inner_cmpwrapper{
(
($docs:expr, $cw_method:ident, $returns:ty)
$(skip_coerce $(@$_skip:tt@)?;)*
$( for[$($implg:tt)*] )?
$(#[$attr:meta])*
pub const fn $func:ident $(<$($fnlt:lifetime),* $(,)?>)?(
$($idents:ident)* : $l_ty:ty,
$rhs:ident: $r_ty:ty $(,)*
) -> $ret:ty $block:block
) => {
$crate::__priv_std_kind_impl!{
$(skip_coerce $(@$_skip@)?;)*
impl[$($($implg)*)?] $l_ty
}
impl<$($($implg)*)?> $crate::__::CmpWrapper<$l_ty> {
#[doc = $docs]
#[inline]
pub const fn $cw_method<$($($fnlt,)*)?>(
&self,
other: $crate::__priv_ref_if_nonref!(($($idents)*) $r_ty),
) -> $returns {
$func(
$crate::__priv_copy_if_nonref!(($($idents)*) self.0),
$crate::__priv_deref_if_nonref!(($($idents)*) other)
)
}
}
}
}
#[cfg(not(feature = "cmp"))]
#[doc(hidden)]
#[macro_export]
macro_rules! __delegate_const_eq{
( $($input:tt)* )=>{
$crate::__priv_delegate_const_inner_fn!{ $($input)* }
}
}
#[cfg(feature = "cmp")]
#[doc(hidden)]
#[macro_export]
macro_rules! __delegate_const_eq{
( $($input:tt)* )=>{
$crate::__priv_delegate_const_inner_fn!{ $($input)* }
$crate::__priv_delegate_const_inner_cmpwrapper!{
(
"Compares `self` and `other` for equality.",
const_eq,
bool
)
$($input)*
}
};
}
#[cfg(not(feature = "cmp"))]
#[doc(hidden)]
#[macro_export]
macro_rules! __delegate_const_ord{
($($input:tt)*)=>{
$crate::__priv_delegate_const_inner_fn!{ $($input)* }
}
}
#[cfg(feature = "cmp")]
#[doc(hidden)]
#[macro_export]
macro_rules! __delegate_const_ord{
( $($input:tt)* )=>{
$crate::__priv_delegate_const_inner_fn!{ $($input)* }
$crate::__priv_delegate_const_inner_cmpwrapper!{
(
"Compares `self` and `other` for ordering.",
const_cmp,
$crate::__::Ordering
)
skip_coerce;
$($input)*
}
};
}
#[cfg(feature = "cmp")]
#[doc(hidden)]
#[macro_export]
macro_rules! __priv_copy_if_nonref {
((ref $ident:ident) $expr:expr) => {
&$expr
};
((copy $ident:ident) $expr:expr) => {
$expr
};
}
#[cfg(feature = "cmp")]
#[doc(hidden)]
#[macro_export]
macro_rules! __priv_deref_if_nonref {
((ref $ident:ident) $expr:expr) => {
$expr
};
((copy $ident:ident) $expr:expr) => {
*$expr
};
}
#[cfg(feature = "cmp")]
#[doc(hidden)]
#[macro_export]
macro_rules! __priv_ref_if_nonref {
((ref $ident:ident) $ty:ty) => {
$ty
};
((copy $ident:ident) $ty:ty) => {
&$ty
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __priv_get_pati_ident {
(ref $ident:ident) => {
$ident
};
(copy $ident:ident) => {
$ident
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __priv_std_kind_impl {
(
impl[$($impl:tt)*] $self:ty
$(where[ $($where_:tt)* ])?
)=>{
impl<$($impl)*> $crate::__::ConstCmp for $self
where
$($($where_)*)?
{
type Kind = $crate::__::IsStdKind;
}
impl<$($impl)* __T> $crate::__::IsAConstCmp<$crate::__::IsStdKind, $self, __T>
where
$($($where_)*)?
{
#[inline(always)]
pub const fn coerce(self, reference: &$self) -> $crate::__::CmpWrapper<$self> {
$crate::__::CmpWrapper(*reference)
}
}
};
(skip_coerce $($anything:tt)*)=>{};
}
#[cfg(feature = "cmp")]
#[cfg_attr(feature = "docsrs", doc(cfg(feature = "cmp")))]
#[macro_export]
macro_rules! coerce_to_cmp {
($reference:expr $(,)*) => {{
match $reference {
ref reference => {
let marker = $crate::__::IsAConstCmp::NEW;
if false {
marker.infer_type(reference);
}
marker.coerce(reference)
}
}
}};
($left:expr, $right:expr $(,)*) => {{
match (&$left, &$right) {
(left, right) => {
let l_marker = $crate::__::IsAConstCmp::NEW;
let r_marker = $crate::__::IsAConstCmp::NEW;
if false {
l_marker.infer_type(left);
r_marker.infer_type(right);
}
(l_marker.coerce(left), r_marker.unreference(right))
}
}
}};
}