1use crate::{cast, Cast, CheckedCast, Round, UnwrappedCast};
17use core::fmt::{Debug, Display, Formatter, LowerExp, Result as FmtResult, UpperExp};
18
19macro_rules! convert {
20 ($($Src:ty),* => $Dst:ty) => { $(
21 impl Cast<$Dst> for $Src {
22 #[inline]
23 fn cast(self) -> $Dst {
24 self as $Dst
25 }
26 }
27
28 impl CheckedCast<$Dst> for $Src {
29 #[inline]
30 fn checked_cast(self) -> Option<$Dst> {
31 Some(cast(self))
32 }
33 }
34
35 impl UnwrappedCast<$Dst> for $Src {
36 #[inline]
37 fn unwrapped_cast(self) -> $Dst {
38 cast(self)
39 }
40 }
41 )* };
42}
43
44convert! { i8, i16, i32, i64, i128, isize, u8, u16, u32, u64, u128, usize, f32, f64 => f32 }
45convert! { i8, i16, i32, i64, i128, isize, u8, u16, u32, u64, u128, usize, f32, f64 => f64 }
46
47impl<T: Display> Display for Round<T> {
48 fn fmt(&self, f: &mut Formatter) -> FmtResult {
49 Display::fmt(&self.0, f)
50 }
51}
52
53impl<T: Debug> Debug for Round<T> {
54 fn fmt(&self, f: &mut Formatter) -> FmtResult {
55 Debug::fmt(&self.0, f)
56 }
57}
58
59impl<T: LowerExp> LowerExp for Round<T> {
60 fn fmt(&self, f: &mut Formatter) -> FmtResult {
61 LowerExp::fmt(&self.0, f)
62 }
63}
64
65impl<T: UpperExp> UpperExp for Round<T> {
66 fn fmt(&self, f: &mut Formatter) -> FmtResult {
67 UpperExp::fmt(&self.0, f)
68 }
69}