@@ -31,7 +31,19 @@ macro_rules! fmt_impls {
3131}
3232
3333macro_rules! convert_impls {
34- ( $type: ident, $t8: ident, $t16: ident, $t32: ident, $t64: ident, $t128: ident, $ot8: ident, $ot16: ident, $ot32: ident) => {
34+ (
35+ $type: ident,
36+ $t8: ident,
37+ $t16: ident,
38+ $t32: ident,
39+ $t64: ident,
40+ $t128: ident,
41+ $tsize: ident,
42+ $ot8: ident,
43+ $ot16: ident,
44+ $ot32: ident,
45+ $otsize: ident
46+ ) => {
3547 impl :: core:: convert:: From <$t8> for $type {
3648 fn from( val: $t8) -> Self {
3749 Self ( $t64:: from( val) )
@@ -68,6 +80,26 @@ macro_rules! convert_impls {
6880 }
6981 }
7082
83+ impl :: core:: convert:: TryFrom <$tsize> for $type {
84+ type Error = crate :: error:: TryFromIntError ;
85+
86+ fn try_from( val: $tsize) -> Result <Self , crate :: error:: TryFromIntError > {
87+ $t64:: try_from( val)
88+ . map_err( |_| crate :: error:: TryFromIntError :: new( ) )
89+ . and_then( $type:: try_from)
90+ }
91+ }
92+
93+ impl :: core:: convert:: TryFrom <$otsize> for $type {
94+ type Error = crate :: error:: TryFromIntError ;
95+
96+ fn try_from( val: $otsize) -> Result <Self , crate :: error:: TryFromIntError > {
97+ $t64:: try_from( val)
98+ . map_err( |_| crate :: error:: TryFromIntError :: new( ) )
99+ . and_then( $type:: try_from)
100+ }
101+ }
102+
71103 impl :: core:: convert:: TryFrom <$type> for $t8 {
72104 type Error = :: core:: num:: TryFromIntError ;
73105
@@ -128,6 +160,22 @@ macro_rules! convert_impls {
128160 }
129161 }
130162
163+ impl :: core:: convert:: TryFrom <$type> for $tsize {
164+ type Error = :: core:: num:: TryFromIntError ;
165+
166+ fn try_from( val: $type) -> Result <Self , :: core:: num:: TryFromIntError > {
167+ Self :: try_from( val. 0 )
168+ }
169+ }
170+
171+ impl :: core:: convert:: TryFrom <$type> for $otsize {
172+ type Error = :: core:: num:: TryFromIntError ;
173+
174+ fn try_from( val: $type) -> Result <Self , :: core:: num:: TryFromIntError > {
175+ Self :: try_from( val. 0 )
176+ }
177+ }
178+
131179 impl :: core:: convert:: From <$type> for f64 {
132180 fn from( val: $type) -> Self {
133181 val. 0 as f64
0 commit comments