use crate::type_level::to_value_traits::ToUsize;
use crate::NestedFieldPath;
#[cfg(all(feature = "use_const_str", not(feature = "disable_const_str")))]
macro_rules! declare_const_impls {
() => {
use crate::const_generic_utils::str_to_usize;
impl<const S: &'static str> ToUsize for crate::__TStrPriv<S> {
const USIZE: usize = str_to_usize(S);
}
};
}
#[cfg(all(feature = "use_const_str", not(feature = "disable_const_str")))]
declare_const_impls! {}
#[cfg(any(not(feature = "use_const_str"), feature = "disable_const_str"))]
mod tstr_type_param {
use crate::__TStrPriv;
use crate::type_level::to_value_traits::{ToDigit, ToUsize};
macro_rules! impl_to_usize {
( $($typ:ident)* ) => (
impl<$($typ,)*> ToUsize for __TStrPriv<($($typ,)*)>
where
$($typ:ToDigit,)*
{
const USIZE:usize={
#[allow(unused_mut)]
let mut num:usize=0;
$(
num*=10;
num+=$typ::DIGIT as usize;
)*
num
};
}
)
}
impl_to_usize! {}
impl_to_usize! { P0 }
impl_to_usize! { P0 P1 }
impl_to_usize! { P0 P1 P2 }
impl_to_usize! { P0 P1 P2 P3 }
impl_to_usize! { P0 P1 P2 P3 P4 }
impl_to_usize! { P0 P1 P2 P3 P4 P5 }
impl_to_usize! { P0 P1 P2 P3 P4 P5 P6 }
impl_to_usize! { P0 P1 P2 P3 P4 P5 P6 P7 }
impl_to_usize! { P0 P1 P2 P3 P4 P5 P6 P7 P8 }
impl_to_usize! { P0 P1 P2 P3 P4 P5 P6 P7 P8 P9 }
impl_to_usize! { P0 P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 }
impl_to_usize! { P0 P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 }
impl_to_usize! { P0 P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12 }
impl_to_usize! { P0 P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12 P13 }
impl_to_usize! { P0 P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12 P13 P14 }
impl_to_usize! { P0 P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12 P13 P14 P15 }
impl_to_usize! { P0 P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12 P13 P14 P15 P16 }
impl_to_usize! { P0 P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12 P13 P14 P15 P16 P17 }
impl_to_usize! { P0 P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12 P13 P14 P15 P16 P17 P18 }
impl_to_usize! { P0 P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12 P13 P14 P15 P16 P17 P18 P19 }
}
impl<S> ToUsize for NestedFieldPath<(S,)>
where
S: ToUsize,
{
const USIZE: usize = S::USIZE;
}