From 2cab0deb97a09ace497c16303095f9905e1d6807 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=9F=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=BE=D0=B2=20=5BArtyom=20Pavlov=5D?= Date: Tue, 31 Jul 2018 04:07:11 +0300 Subject: [PATCH] don't duplicate impls --- src/libcore/time.rs | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/src/libcore/time.rs b/src/libcore/time.rs index cd98f51f5cd..fff47ac44ef 100644 --- a/src/libcore/time.rs +++ b/src/libcore/time.rs @@ -507,7 +507,7 @@ impl Mul for u32 { type Output = Duration; fn mul(self, rhs: Duration) -> Duration { - rhs.checked_mul(self).expect("overflow when multiplying scalar by duration") + rhs * self } } @@ -540,22 +540,7 @@ impl Mul for f64 { type Output = Duration; fn mul(self, rhs: Duration) -> Duration { - const NPS: f64 = NANOS_PER_SEC as f64; - let nanos_f64 = self * (NPS * (rhs.secs as f64) + (rhs.nanos as f64)); - if !nanos_f64.is_finite() { - panic!("got non-finite value when multiplying float by duration"); - } - if nanos_f64 > MAX_NANOS_F64 { - panic!("overflow when multiplying float by duration"); - } - if nanos_f64 < 0.0 { - panic!("underflow when multiplying float by duration"); - } - let nanos_u128 = nanos_f64 as u128; - Duration { - secs: (nanos_u128 / (NANOS_PER_SEC as u128)) as u64, - nanos: (nanos_u128 % (NANOS_PER_SEC as u128)) as u32, - } + rhs * self } }