#[allow(deprecated)]
use crate::StaticCast;
use crate::{Cast, CheckedCast, Round};
use core::fmt::{Display, Formatter, LowerExp, Result as FmtResult, UpperExp};
macro_rules! convert {
($($Src:ty),* => $Dst:ty) => { $(
impl Cast<$Dst> for $Src {
#[inline]
fn cast(self) -> $Dst {
self as $Dst
}
}
impl CheckedCast<$Dst> for $Src {
#[inline]
fn checked_cast(self) -> Option<$Dst> {
Some(self.cast())
}
}
#[allow(deprecated)]
impl StaticCast<$Dst> for $Src {
#[inline]
fn static_cast(self) -> Option<$Dst> {
Some(self.cast())
}
}
)* };
}
convert! { i8, i16, i32, i64, i128, isize, u8, u16, u32, u64, u128, usize, f32, f64 => f32 }
convert! { i8, i16, i32, i64, i128, isize, u8, u16, u32, u64, u128, usize, f32, f64 => f64 }
impl<T: Display> Display for Round<T> {
fn fmt(&self, f: &mut Formatter) -> FmtResult {
Display::fmt(&self.0, f)
}
}
impl<T: LowerExp> LowerExp for Round<T> {
fn fmt(&self, f: &mut Formatter) -> FmtResult {
LowerExp::fmt(&self.0, f)
}
}
impl<T: UpperExp> UpperExp for Round<T> {
fn fmt(&self, f: &mut Formatter) -> FmtResult {
UpperExp::fmt(&self.0, f)
}
}