use num_traits as num;
use std::fmt;
pub trait Counter:
num::Num
+ num::ToPrimitive
+ num::FromPrimitive
+ num::Saturating
+ num::CheckedSub
+ num::CheckedAdd
+ Copy
+ PartialOrd<Self>
+ fmt::Debug
{
fn as_f64(&self) -> f64;
fn as_u64(&self) -> u64;
}
impl Counter for u8 {
#[inline]
fn as_f64(&self) -> f64 {
f64::from(*self)
}
#[inline]
fn as_u64(&self) -> u64 {
u64::from(*self)
}
}
impl Counter for u16 {
#[inline]
fn as_f64(&self) -> f64 {
f64::from(*self)
}
#[inline]
fn as_u64(&self) -> u64 {
u64::from(*self)
}
}
impl Counter for u32 {
#[inline]
fn as_f64(&self) -> f64 {
f64::from(*self)
}
#[inline]
fn as_u64(&self) -> u64 {
u64::from(*self)
}
}
impl Counter for u64 {
#[inline]
fn as_f64(&self) -> f64 {
*self as f64
}
#[inline]
fn as_u64(&self) -> u64 {
*self
}
}