1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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;
}