pub mod volume; type Percent = u8; pub fn round(f: F, digits: I) -> f64 where F: Into, I: Into + Copy, { (f.into() * 10_f64.powi(digits.into())).round() / 10_f64.powi(digits.into()) } #[cfg(test)] mod tests { #[test] fn round() { assert_eq!(super::round(0.123456789, 3), 0.123); } }