macro_rules! impl_marker {
($t:ident for $($ty:ty),* $(,)?) => ($(
impl $t for $ty {}
)*)
}
mod private {
pub trait Sealed {}
impl_marker!(Sealed for u8, u16, u32, u64, usize);
}
pub trait ByteSize: private::Sealed {}
impl_marker!(ByteSize for u8, u16, u32, u64, usize);
pub trait Displayable: ByteSize {
fn canonicalize(&self) -> f64;
}
macro_rules! impl_displayable {
($($ty:ty),* $(,)?) => ($(
impl Displayable for $ty {
fn canonicalize(&self) -> f64 {
*self as f64
}
}
)*)
}
impl_displayable!(u8, u16, u32, u64, usize);