From 3d9e230b657b549e6d7496fcedb043ff2cdb11f4 Mon Sep 17 00:00:00 2001 From: David Peter Date: Mon, 5 Oct 2026 14:20:23 +0200 Subject: [PATCH] Get rid of value_in --- src/quantity/mod.rs | 36 +++++++----------------------------- 1 file changed, 7 insertions(+), 29 deletions(-) diff --git a/src/quantity/mod.rs b/src/quantity/mod.rs index df6db4f..4f7ed67 100644 --- a/src/quantity/mod.rs +++ b/src/quantity/mod.rs @@ -26,10 +26,6 @@ pub trait TimeQuantity { Time::new::(0.0) } - fn value_in(&self, u: U) -> f64 - where - U: si::time::Unit + Conversion; - fn suitable_unit(&self) -> TimeUnit; fn format(&self, u: TimeUnit, precision: Option) -> String; @@ -38,13 +34,6 @@ pub trait TimeQuantity { } impl TimeQuantity for Time { - fn value_in(&self, _u: U) -> f64 - where - U: si::time::Unit + Conversion, - { - self.get::() - } - fn suitable_unit(&self) -> TimeUnit { if *self < Time::new::(1.0) { TimeUnit::MicroSecond @@ -93,23 +82,12 @@ pub trait InformationQuantity { Information::new::(0.) } - fn value_in(&self, u: U) -> f64 - where - U: si::information::Unit + Conversion; - fn to_string(&self, u: U) -> String where U: si::information::Unit + Conversion; } impl InformationQuantity for Information { - fn value_in(&self, _u: U) -> f64 - where - U: si::information::Unit + Conversion, - { - self.get::() - } - fn to_string(&self, u: U) -> String where U: si::information::Unit + Conversion, @@ -128,7 +106,7 @@ pub trait UnsafeRawValue { impl UnsafeRawValue for Time { fn unsafe_raw_value(&self) -> f64 { - self.value_in(second) + self.get::() } fn unsafe_from_raw_value(value: f64) -> Self { @@ -138,7 +116,7 @@ impl UnsafeRawValue for Time { impl UnsafeRawValue for Information { fn unsafe_raw_value(&self) -> f64 { - self.value_in(byte) + self.get::() } fn unsafe_from_raw_value(value: f64) -> Self { @@ -194,21 +172,21 @@ pub fn modified_zscores(values: &[Q]) -> Vec { #[test] fn test_time() { let time = Time::new::(123.4); - assert_eq!(time.value_in(millisecond), 123.4); + assert_eq!(time.get::(), 123.4); - let time_s = time.value_in(second); + let time_s = time.get::(); approx::assert_relative_eq!(time_s, 0.1234); - let time_us = time.value_in(microsecond); + let time_us = time.get::(); approx::assert_relative_eq!(time_us, 123400.0); } #[test] fn test_information() { let information = Information::new::(8.); - assert_eq!(information.value_in(byte), 8192.); + assert_eq!(information.get::(), 8192.); - let information_kib = information.value_in(kibibyte); + let information_kib = information.get::(); assert_eq!(information_kib, 8.); }