use std::num::ParseFloatError;
use std::str::FromStr;
use super::c::C;
use super::k::K;
#[derive(Debug, Copy, PartialEq)]
pub struct F(pub f64);
impl FromStr for F {
type Err = ParseFloatError; fn from_str(s: &str) -> Result<Self, Self::Err> {
return Ok(F(s.replace(" ","").parse::<f64>()?));
}
}
impl ToString for F {
fn to_string(&self) -> String {
return format!("{}°F", self.0);
}
}
impl From<usize> for F {
fn from(i: usize) -> Self {
return F(i as f64);
}
}
impl From<f64> for F {
fn from(f: f64) -> Self {
return F(f);
}
}
impl From<C> for F {
fn from(c: C) -> Self {
return Self(crate::utils::c_to_f(c.0));
}
}
impl From<K> for F {
fn from(k: K) -> Self {
return Self(crate::utils::k_to_f(k.0))
}
}