use std::fmt::Display;
pub trait PlotValue:
Copy
+ PartialOrd
+ std::ops::Add<Output = Self>
+ std::ops::Sub<Output = Self>
+ std::ops::Mul<Output = Self>
+ std::ops::Div<Output = Self>
+ Display
+ 'static
{
fn to_f32(self) -> f32;
fn max_value() -> Self;
fn min_value() -> Self;
fn epsilon() -> Self;
fn from_f32(val: f32) -> Self;
}
impl PlotValue for f32 {
fn to_f32(self) -> f32 {
self
}
fn max_value() -> Self {
f32::MAX
}
fn min_value() -> Self {
f32::MIN
}
fn epsilon() -> Self {
f32::EPSILON
}
fn from_f32(val: f32) -> Self {
val
}
}
impl PlotValue for f64 {
fn to_f32(self) -> f32 {
self as f32
}
fn max_value() -> Self {
f64::MAX
}
fn min_value() -> Self {
f64::MIN
}
fn epsilon() -> Self {
f64::EPSILON
}
fn from_f32(val: f32) -> Self {
val as f64
}
}
impl PlotValue for i32 {
fn to_f32(self) -> f32 {
self as f32
}
fn max_value() -> Self {
i32::MAX
}
fn min_value() -> Self {
i32::MIN
}
fn epsilon() -> Self {
1
}
fn from_f32(val: f32) -> Self {
val as i32
}
}
impl PlotValue for i64 {
fn to_f32(self) -> f32 {
self as f32
}
fn max_value() -> Self {
i64::MAX
}
fn min_value() -> Self {
i64::MIN
}
fn epsilon() -> Self {
1
}
fn from_f32(val: f32) -> Self {
val as i64
}
}