/rust/registry/src/index.crates.io-1949cf8c6b5b557f/bnum-0.12.1/src/cast/mod.rs
Line | Count | Source |
1 | | //! Panic-free casting between numeric types. |
2 | | |
3 | | /// Backend implementation trait for panic-free casting between numeric types. |
4 | | pub trait CastFrom<T> { |
5 | | fn cast_from(from: T) -> Self; |
6 | | } |
7 | | |
8 | | #[cfg(test)] |
9 | | pub(crate) trait CastTo<U> { |
10 | | fn cast_to(self) -> U; |
11 | | } |
12 | | |
13 | | macro_rules! as_trait_doc { |
14 | | () => { |
15 | | "Trait which allows panic-free casting between numeric types. |
16 | | |
17 | | The behavior matches the behavior of the `as` conversion operator between primitive integers. This trait can be used to convert between bnum's integer types, as well as between bnum's integer types and Rust's primitive integers. Conversions between Rust's primitive integers themselves are also defined for consistency." |
18 | | }; |
19 | | } |
20 | | |
21 | | macro_rules! as_method_doc { |
22 | | () => { |
23 | | "Casts `self` to type `T`. The [semantics of numeric casting](https://doc.rust-lang.org/reference/expressions/operator-expr.html#semantics) with the `as` operator are followed, so `<T as As>::as_::<U>` can be used in the same way as `T as U` for numeric conversions. |
24 | | |
25 | | # Examples |
26 | | |
27 | | ``` |
28 | | use bnum::types::{U256, I512, I256, U1024}; |
29 | | use bnum::cast::As; |
30 | | |
31 | | // Cast `u64` to `U256`: |
32 | | let a = 399872465243u64; |
33 | | let b: U256 = a.as_(); |
34 | | assert_eq!(a.as_::<u16>(), b.as_()); |
35 | | |
36 | | // Cast `i128` to `I512`: |
37 | | let c = -2098409234529234584094i128; |
38 | | let d = c.as_::<I512>(); |
39 | | //assert_eq!(c.as::<I256>(), d.as_()); |
40 | | |
41 | | // Cast `I512` to `U1024` (result will be sign-extended with leading ones): |
42 | | let e: U1024 = d.as_(); |
43 | | assert_eq!(d, e.as_()); |
44 | | |
45 | | // Cast `U256` to `f64` and back: |
46 | | let f: f64 = b.as_(); |
47 | | assert_eq!(b, f.as_()); |
48 | | ```" |
49 | | }; |
50 | | } |
51 | | |
52 | | #[cfg(feature = "nightly")] |
53 | | macro_rules! as_trait { |
54 | | () => { |
55 | | // impl<T, U> const CastTo<U> for T |
56 | | #[cfg(test)] |
57 | | impl<T, U> CastTo<U> for T |
58 | | where |
59 | | // U: ~const CastFrom<T>, |
60 | | U: CastFrom<T>, |
61 | | { |
62 | | fn cast_to(self) -> U { |
63 | | U::cast_from(self) |
64 | | } |
65 | | } |
66 | | |
67 | | #[doc = as_trait_doc!()] |
68 | | // #[const_trait] |
69 | | pub trait As { |
70 | | #[doc = as_method_doc!()] |
71 | | fn as_<T>(self) -> T |
72 | | where |
73 | | T: CastFrom<Self>, |
74 | | Self: Sized; |
75 | | } |
76 | | |
77 | | // impl<U> const As for U { |
78 | | impl<U> As for U { |
79 | | #[inline] |
80 | | fn as_<T>(self) -> T |
81 | | where |
82 | | // T: ~const CastFrom<Self>, |
83 | | T: CastFrom<Self>, |
84 | | Self: Sized, |
85 | | { |
86 | | T::cast_from(self) |
87 | | } |
88 | | } |
89 | | }; |
90 | | } |
91 | | |
92 | | #[cfg(not(feature = "nightly"))] |
93 | | macro_rules! as_trait { |
94 | | () => { |
95 | | #[cfg(test)] |
96 | | impl<T, U> CastTo<U> for T |
97 | | where |
98 | | U: CastFrom<T>, |
99 | | { |
100 | | fn cast_to(self) -> U { |
101 | | U::cast_from(self) |
102 | | } |
103 | | } |
104 | | |
105 | | #[doc = as_trait_doc!()] |
106 | | pub trait As { |
107 | | #[doc = as_method_doc!()] |
108 | | fn as_<T>(self) -> T |
109 | | where |
110 | | T: CastFrom<Self>, |
111 | | Self: Sized; |
112 | | } |
113 | | |
114 | | impl<U> As for U { |
115 | | #[inline] |
116 | 0 | fn as_<T>(self) -> T |
117 | 0 | where |
118 | 0 | T: CastFrom<Self>, |
119 | 0 | Self: Sized, |
120 | | { |
121 | 0 | T::cast_from(self) |
122 | 0 | } |
123 | | } |
124 | | }; |
125 | | } |
126 | | |
127 | | as_trait!(); |
128 | | |
129 | | macro_rules! primitive_cast_impl { |
130 | | ($from: ty as [$($ty: ty), *]) => { |
131 | | $( |
132 | | impl CastFrom<$from> for $ty { |
133 | | #[inline] |
134 | 0 | fn cast_from(from: $from) -> Self { |
135 | 0 | from as Self |
136 | 0 | } Unexecuted instantiation: <u16 as bnum::cast::CastFrom<bool>>::cast_from Unexecuted instantiation: <i32 as bnum::cast::CastFrom<u32>>::cast_from Unexecuted instantiation: <i64 as bnum::cast::CastFrom<u32>>::cast_from Unexecuted instantiation: <i128 as bnum::cast::CastFrom<u32>>::cast_from Unexecuted instantiation: <isize as bnum::cast::CastFrom<u32>>::cast_from Unexecuted instantiation: <f32 as bnum::cast::CastFrom<u32>>::cast_from Unexecuted instantiation: <f64 as bnum::cast::CastFrom<u32>>::cast_from Unexecuted instantiation: <u8 as bnum::cast::CastFrom<u64>>::cast_from Unexecuted instantiation: <u16 as bnum::cast::CastFrom<u64>>::cast_from Unexecuted instantiation: <u32 as bnum::cast::CastFrom<u64>>::cast_from Unexecuted instantiation: <u64 as bnum::cast::CastFrom<u64>>::cast_from Unexecuted instantiation: <u32 as bnum::cast::CastFrom<usize>>::cast_from Unexecuted instantiation: <u64 as bnum::cast::CastFrom<usize>>::cast_from Unexecuted instantiation: <u128 as bnum::cast::CastFrom<usize>>::cast_from Unexecuted instantiation: <usize as bnum::cast::CastFrom<usize>>::cast_from Unexecuted instantiation: <i8 as bnum::cast::CastFrom<usize>>::cast_from Unexecuted instantiation: <i16 as bnum::cast::CastFrom<usize>>::cast_from Unexecuted instantiation: <i32 as bnum::cast::CastFrom<usize>>::cast_from Unexecuted instantiation: <i64 as bnum::cast::CastFrom<usize>>::cast_from Unexecuted instantiation: <i128 as bnum::cast::CastFrom<usize>>::cast_from Unexecuted instantiation: <isize as bnum::cast::CastFrom<usize>>::cast_from Unexecuted instantiation: <f32 as bnum::cast::CastFrom<usize>>::cast_from Unexecuted instantiation: <f64 as bnum::cast::CastFrom<usize>>::cast_from Unexecuted instantiation: <u8 as bnum::cast::CastFrom<i8>>::cast_from Unexecuted instantiation: <u16 as bnum::cast::CastFrom<i8>>::cast_from Unexecuted instantiation: <u32 as bnum::cast::CastFrom<i8>>::cast_from Unexecuted instantiation: <u64 as bnum::cast::CastFrom<i8>>::cast_from Unexecuted instantiation: <u128 as bnum::cast::CastFrom<i8>>::cast_from Unexecuted instantiation: <usize as bnum::cast::CastFrom<i8>>::cast_from Unexecuted instantiation: <i8 as bnum::cast::CastFrom<i8>>::cast_from Unexecuted instantiation: <i16 as bnum::cast::CastFrom<i8>>::cast_from Unexecuted instantiation: <i32 as bnum::cast::CastFrom<i8>>::cast_from Unexecuted instantiation: <i64 as bnum::cast::CastFrom<i8>>::cast_from Unexecuted instantiation: <i128 as bnum::cast::CastFrom<i8>>::cast_from Unexecuted instantiation: <isize as bnum::cast::CastFrom<i8>>::cast_from Unexecuted instantiation: <f32 as bnum::cast::CastFrom<i8>>::cast_from Unexecuted instantiation: <f64 as bnum::cast::CastFrom<i8>>::cast_from Unexecuted instantiation: <u32 as bnum::cast::CastFrom<bool>>::cast_from Unexecuted instantiation: <u128 as bnum::cast::CastFrom<u64>>::cast_from Unexecuted instantiation: <usize as bnum::cast::CastFrom<u64>>::cast_from Unexecuted instantiation: <i8 as bnum::cast::CastFrom<u64>>::cast_from Unexecuted instantiation: <i16 as bnum::cast::CastFrom<u64>>::cast_from Unexecuted instantiation: <i32 as bnum::cast::CastFrom<u64>>::cast_from Unexecuted instantiation: <i64 as bnum::cast::CastFrom<u64>>::cast_from Unexecuted instantiation: <i128 as bnum::cast::CastFrom<u64>>::cast_from Unexecuted instantiation: <isize as bnum::cast::CastFrom<u64>>::cast_from Unexecuted instantiation: <f32 as bnum::cast::CastFrom<u64>>::cast_from Unexecuted instantiation: <f64 as bnum::cast::CastFrom<u64>>::cast_from Unexecuted instantiation: <u8 as bnum::cast::CastFrom<u128>>::cast_from Unexecuted instantiation: <u16 as bnum::cast::CastFrom<u128>>::cast_from Unexecuted instantiation: <u32 as bnum::cast::CastFrom<u128>>::cast_from Unexecuted instantiation: <u64 as bnum::cast::CastFrom<u128>>::cast_from Unexecuted instantiation: <u128 as bnum::cast::CastFrom<u128>>::cast_from Unexecuted instantiation: <usize as bnum::cast::CastFrom<u128>>::cast_from Unexecuted instantiation: <i8 as bnum::cast::CastFrom<u128>>::cast_from Unexecuted instantiation: <i16 as bnum::cast::CastFrom<u128>>::cast_from Unexecuted instantiation: <i32 as bnum::cast::CastFrom<u128>>::cast_from Unexecuted instantiation: <i64 as bnum::cast::CastFrom<u128>>::cast_from Unexecuted instantiation: <i128 as bnum::cast::CastFrom<u128>>::cast_from Unexecuted instantiation: <isize as bnum::cast::CastFrom<u128>>::cast_from Unexecuted instantiation: <f32 as bnum::cast::CastFrom<u128>>::cast_from Unexecuted instantiation: <f64 as bnum::cast::CastFrom<u128>>::cast_from Unexecuted instantiation: <u8 as bnum::cast::CastFrom<usize>>::cast_from Unexecuted instantiation: <u16 as bnum::cast::CastFrom<usize>>::cast_from Unexecuted instantiation: <u8 as bnum::cast::CastFrom<i16>>::cast_from Unexecuted instantiation: <u16 as bnum::cast::CastFrom<i16>>::cast_from Unexecuted instantiation: <u32 as bnum::cast::CastFrom<i16>>::cast_from Unexecuted instantiation: <u64 as bnum::cast::CastFrom<i16>>::cast_from Unexecuted instantiation: <u128 as bnum::cast::CastFrom<i16>>::cast_from Unexecuted instantiation: <usize as bnum::cast::CastFrom<i16>>::cast_from Unexecuted instantiation: <i8 as bnum::cast::CastFrom<i16>>::cast_from Unexecuted instantiation: <i16 as bnum::cast::CastFrom<i16>>::cast_from Unexecuted instantiation: <i32 as bnum::cast::CastFrom<i16>>::cast_from Unexecuted instantiation: <i64 as bnum::cast::CastFrom<i16>>::cast_from Unexecuted instantiation: <i32 as bnum::cast::CastFrom<i64>>::cast_from Unexecuted instantiation: <i64 as bnum::cast::CastFrom<i64>>::cast_from Unexecuted instantiation: <i128 as bnum::cast::CastFrom<i64>>::cast_from Unexecuted instantiation: <isize as bnum::cast::CastFrom<i64>>::cast_from Unexecuted instantiation: <f32 as bnum::cast::CastFrom<i64>>::cast_from Unexecuted instantiation: <f64 as bnum::cast::CastFrom<i64>>::cast_from Unexecuted instantiation: <u8 as bnum::cast::CastFrom<i128>>::cast_from Unexecuted instantiation: <u16 as bnum::cast::CastFrom<i128>>::cast_from Unexecuted instantiation: <u32 as bnum::cast::CastFrom<i128>>::cast_from Unexecuted instantiation: <u64 as bnum::cast::CastFrom<i128>>::cast_from Unexecuted instantiation: <u128 as bnum::cast::CastFrom<i128>>::cast_from Unexecuted instantiation: <usize as bnum::cast::CastFrom<i128>>::cast_from Unexecuted instantiation: <i8 as bnum::cast::CastFrom<i128>>::cast_from Unexecuted instantiation: <i16 as bnum::cast::CastFrom<i128>>::cast_from Unexecuted instantiation: <i32 as bnum::cast::CastFrom<i128>>::cast_from Unexecuted instantiation: <i64 as bnum::cast::CastFrom<i128>>::cast_from Unexecuted instantiation: <i128 as bnum::cast::CastFrom<i128>>::cast_from Unexecuted instantiation: <isize as bnum::cast::CastFrom<i128>>::cast_from Unexecuted instantiation: <f32 as bnum::cast::CastFrom<i128>>::cast_from Unexecuted instantiation: <f64 as bnum::cast::CastFrom<i128>>::cast_from Unexecuted instantiation: <u8 as bnum::cast::CastFrom<isize>>::cast_from Unexecuted instantiation: <u16 as bnum::cast::CastFrom<isize>>::cast_from Unexecuted instantiation: <u32 as bnum::cast::CastFrom<isize>>::cast_from Unexecuted instantiation: <u64 as bnum::cast::CastFrom<isize>>::cast_from Unexecuted instantiation: <u128 as bnum::cast::CastFrom<isize>>::cast_from Unexecuted instantiation: <usize as bnum::cast::CastFrom<isize>>::cast_from Unexecuted instantiation: <u64 as bnum::cast::CastFrom<bool>>::cast_from Unexecuted instantiation: <i128 as bnum::cast::CastFrom<i16>>::cast_from Unexecuted instantiation: <isize as bnum::cast::CastFrom<i16>>::cast_from Unexecuted instantiation: <f32 as bnum::cast::CastFrom<i16>>::cast_from Unexecuted instantiation: <f64 as bnum::cast::CastFrom<i16>>::cast_from Unexecuted instantiation: <u8 as bnum::cast::CastFrom<i32>>::cast_from Unexecuted instantiation: <u16 as bnum::cast::CastFrom<i32>>::cast_from Unexecuted instantiation: <u32 as bnum::cast::CastFrom<i32>>::cast_from Unexecuted instantiation: <u64 as bnum::cast::CastFrom<i32>>::cast_from Unexecuted instantiation: <u128 as bnum::cast::CastFrom<i32>>::cast_from Unexecuted instantiation: <usize as bnum::cast::CastFrom<i32>>::cast_from Unexecuted instantiation: <i8 as bnum::cast::CastFrom<i32>>::cast_from Unexecuted instantiation: <i16 as bnum::cast::CastFrom<i32>>::cast_from Unexecuted instantiation: <i32 as bnum::cast::CastFrom<i32>>::cast_from Unexecuted instantiation: <i64 as bnum::cast::CastFrom<i32>>::cast_from Unexecuted instantiation: <i128 as bnum::cast::CastFrom<i32>>::cast_from Unexecuted instantiation: <isize as bnum::cast::CastFrom<i32>>::cast_from Unexecuted instantiation: <f32 as bnum::cast::CastFrom<i32>>::cast_from Unexecuted instantiation: <f64 as bnum::cast::CastFrom<i32>>::cast_from Unexecuted instantiation: <u8 as bnum::cast::CastFrom<i64>>::cast_from Unexecuted instantiation: <u16 as bnum::cast::CastFrom<i64>>::cast_from Unexecuted instantiation: <u32 as bnum::cast::CastFrom<i64>>::cast_from Unexecuted instantiation: <u64 as bnum::cast::CastFrom<i64>>::cast_from Unexecuted instantiation: <u128 as bnum::cast::CastFrom<i64>>::cast_from Unexecuted instantiation: <usize as bnum::cast::CastFrom<i64>>::cast_from Unexecuted instantiation: <i8 as bnum::cast::CastFrom<i64>>::cast_from Unexecuted instantiation: <i16 as bnum::cast::CastFrom<i64>>::cast_from Unexecuted instantiation: <i8 as bnum::cast::CastFrom<isize>>::cast_from Unexecuted instantiation: <i16 as bnum::cast::CastFrom<isize>>::cast_from Unexecuted instantiation: <i32 as bnum::cast::CastFrom<isize>>::cast_from Unexecuted instantiation: <i64 as bnum::cast::CastFrom<isize>>::cast_from Unexecuted instantiation: <i128 as bnum::cast::CastFrom<isize>>::cast_from Unexecuted instantiation: <isize as bnum::cast::CastFrom<isize>>::cast_from Unexecuted instantiation: <f32 as bnum::cast::CastFrom<isize>>::cast_from Unexecuted instantiation: <f64 as bnum::cast::CastFrom<isize>>::cast_from Unexecuted instantiation: <u8 as bnum::cast::CastFrom<f32>>::cast_from Unexecuted instantiation: <u16 as bnum::cast::CastFrom<f32>>::cast_from Unexecuted instantiation: <u128 as bnum::cast::CastFrom<bool>>::cast_from Unexecuted instantiation: <u32 as bnum::cast::CastFrom<f32>>::cast_from Unexecuted instantiation: <u64 as bnum::cast::CastFrom<f32>>::cast_from Unexecuted instantiation: <u128 as bnum::cast::CastFrom<f32>>::cast_from Unexecuted instantiation: <usize as bnum::cast::CastFrom<f32>>::cast_from Unexecuted instantiation: <i8 as bnum::cast::CastFrom<f32>>::cast_from Unexecuted instantiation: <i16 as bnum::cast::CastFrom<f32>>::cast_from Unexecuted instantiation: <i32 as bnum::cast::CastFrom<f32>>::cast_from Unexecuted instantiation: <i64 as bnum::cast::CastFrom<f32>>::cast_from Unexecuted instantiation: <i128 as bnum::cast::CastFrom<f32>>::cast_from Unexecuted instantiation: <isize as bnum::cast::CastFrom<f32>>::cast_from Unexecuted instantiation: <f32 as bnum::cast::CastFrom<f32>>::cast_from Unexecuted instantiation: <f64 as bnum::cast::CastFrom<f32>>::cast_from Unexecuted instantiation: <u8 as bnum::cast::CastFrom<f64>>::cast_from Unexecuted instantiation: <u16 as bnum::cast::CastFrom<f64>>::cast_from Unexecuted instantiation: <u32 as bnum::cast::CastFrom<f64>>::cast_from Unexecuted instantiation: <u64 as bnum::cast::CastFrom<f64>>::cast_from Unexecuted instantiation: <u128 as bnum::cast::CastFrom<f64>>::cast_from Unexecuted instantiation: <usize as bnum::cast::CastFrom<f64>>::cast_from Unexecuted instantiation: <i8 as bnum::cast::CastFrom<f64>>::cast_from Unexecuted instantiation: <i16 as bnum::cast::CastFrom<f64>>::cast_from Unexecuted instantiation: <i32 as bnum::cast::CastFrom<f64>>::cast_from Unexecuted instantiation: <i64 as bnum::cast::CastFrom<f64>>::cast_from Unexecuted instantiation: <i128 as bnum::cast::CastFrom<f64>>::cast_from Unexecuted instantiation: <isize as bnum::cast::CastFrom<f64>>::cast_from Unexecuted instantiation: <f32 as bnum::cast::CastFrom<f64>>::cast_from Unexecuted instantiation: <f64 as bnum::cast::CastFrom<f64>>::cast_from Unexecuted instantiation: <usize as bnum::cast::CastFrom<bool>>::cast_from Unexecuted instantiation: <i8 as bnum::cast::CastFrom<bool>>::cast_from Unexecuted instantiation: <i16 as bnum::cast::CastFrom<bool>>::cast_from Unexecuted instantiation: <i32 as bnum::cast::CastFrom<bool>>::cast_from Unexecuted instantiation: <i64 as bnum::cast::CastFrom<bool>>::cast_from Unexecuted instantiation: <i128 as bnum::cast::CastFrom<bool>>::cast_from Unexecuted instantiation: <isize as bnum::cast::CastFrom<u8>>::cast_from Unexecuted instantiation: <f32 as bnum::cast::CastFrom<u8>>::cast_from Unexecuted instantiation: <f64 as bnum::cast::CastFrom<u8>>::cast_from Unexecuted instantiation: <char as bnum::cast::CastFrom<u8>>::cast_from Unexecuted instantiation: <u8 as bnum::cast::CastFrom<u16>>::cast_from Unexecuted instantiation: <u16 as bnum::cast::CastFrom<u16>>::cast_from Unexecuted instantiation: <u32 as bnum::cast::CastFrom<u16>>::cast_from Unexecuted instantiation: <u64 as bnum::cast::CastFrom<u16>>::cast_from Unexecuted instantiation: <u128 as bnum::cast::CastFrom<u16>>::cast_from Unexecuted instantiation: <usize as bnum::cast::CastFrom<u16>>::cast_from Unexecuted instantiation: <i8 as bnum::cast::CastFrom<u16>>::cast_from Unexecuted instantiation: <i16 as bnum::cast::CastFrom<u16>>::cast_from Unexecuted instantiation: <i32 as bnum::cast::CastFrom<u16>>::cast_from Unexecuted instantiation: <i64 as bnum::cast::CastFrom<u16>>::cast_from Unexecuted instantiation: <i128 as bnum::cast::CastFrom<u16>>::cast_from Unexecuted instantiation: <isize as bnum::cast::CastFrom<u16>>::cast_from Unexecuted instantiation: <f32 as bnum::cast::CastFrom<u16>>::cast_from Unexecuted instantiation: <f64 as bnum::cast::CastFrom<u16>>::cast_from Unexecuted instantiation: <u8 as bnum::cast::CastFrom<u32>>::cast_from Unexecuted instantiation: <u16 as bnum::cast::CastFrom<u32>>::cast_from Unexecuted instantiation: <u32 as bnum::cast::CastFrom<u32>>::cast_from Unexecuted instantiation: <u64 as bnum::cast::CastFrom<u32>>::cast_from Unexecuted instantiation: <u128 as bnum::cast::CastFrom<u32>>::cast_from Unexecuted instantiation: <usize as bnum::cast::CastFrom<u32>>::cast_from Unexecuted instantiation: <i8 as bnum::cast::CastFrom<u32>>::cast_from Unexecuted instantiation: <i16 as bnum::cast::CastFrom<u32>>::cast_from Unexecuted instantiation: <u8 as bnum::cast::CastFrom<bool>>::cast_from Unexecuted instantiation: <isize as bnum::cast::CastFrom<bool>>::cast_from Unexecuted instantiation: <bool as bnum::cast::CastFrom<bool>>::cast_from Unexecuted instantiation: <u8 as bnum::cast::CastFrom<char>>::cast_from Unexecuted instantiation: <u16 as bnum::cast::CastFrom<char>>::cast_from Unexecuted instantiation: <u32 as bnum::cast::CastFrom<char>>::cast_from Unexecuted instantiation: <u64 as bnum::cast::CastFrom<char>>::cast_from Unexecuted instantiation: <u128 as bnum::cast::CastFrom<char>>::cast_from Unexecuted instantiation: <usize as bnum::cast::CastFrom<char>>::cast_from Unexecuted instantiation: <i8 as bnum::cast::CastFrom<char>>::cast_from Unexecuted instantiation: <i16 as bnum::cast::CastFrom<char>>::cast_from Unexecuted instantiation: <i32 as bnum::cast::CastFrom<char>>::cast_from Unexecuted instantiation: <i64 as bnum::cast::CastFrom<char>>::cast_from Unexecuted instantiation: <i128 as bnum::cast::CastFrom<char>>::cast_from Unexecuted instantiation: <isize as bnum::cast::CastFrom<char>>::cast_from Unexecuted instantiation: <char as bnum::cast::CastFrom<char>>::cast_from Unexecuted instantiation: <u8 as bnum::cast::CastFrom<u8>>::cast_from Unexecuted instantiation: <u16 as bnum::cast::CastFrom<u8>>::cast_from Unexecuted instantiation: <u32 as bnum::cast::CastFrom<u8>>::cast_from Unexecuted instantiation: <u64 as bnum::cast::CastFrom<u8>>::cast_from Unexecuted instantiation: <u128 as bnum::cast::CastFrom<u8>>::cast_from Unexecuted instantiation: <usize as bnum::cast::CastFrom<u8>>::cast_from Unexecuted instantiation: <i8 as bnum::cast::CastFrom<u8>>::cast_from Unexecuted instantiation: <i16 as bnum::cast::CastFrom<u8>>::cast_from Unexecuted instantiation: <i32 as bnum::cast::CastFrom<u8>>::cast_from Unexecuted instantiation: <i64 as bnum::cast::CastFrom<u8>>::cast_from Unexecuted instantiation: <i128 as bnum::cast::CastFrom<u8>>::cast_from |
137 | | } |
138 | | )* |
139 | | }; |
140 | | } |
141 | | |
142 | | macro_rules! multiple_impls { |
143 | | ($($from: ty), *) => { |
144 | | $( |
145 | | primitive_cast_impl!($from as [u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, isize, f32, f64]); |
146 | | )* |
147 | | }; |
148 | | } |
149 | | |
150 | | primitive_cast_impl!(bool as [u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, isize, bool]); |
151 | | primitive_cast_impl!(char as [u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, isize, char]); |
152 | | primitive_cast_impl!(u8 as [u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, isize, f32, f64, char]); |
153 | | multiple_impls!(u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, isize, f32, f64); |
154 | | |
155 | | pub(crate) mod float; |