# HG changeset patch # User unc0rr # Date 1539446665 -7200 # Node ID cd39e87d7a80dcece3b3d15ad89f0193f970ded3 # Parent fbbb4fcd6a75c0337dcc5fe782ace8e3853f5563 inline more operators in fpnum diff -r fbbb4fcd6a75 -r cd39e87d7a80 rust/fpnum/src/lib.rs --- a/rust/fpnum/src/lib.rs Sat Oct 13 00:43:04 2018 +0300 +++ b/rust/fpnum/src/lib.rs Sat Oct 13 18:04:25 2018 +0200 @@ -12,6 +12,7 @@ FPNum::from(numerator) / denominator } + #[inline] fn signum(&self) -> i8 { if self.is_negative { -1 @@ -20,18 +21,22 @@ } } + #[inline] fn is_negative(&self) -> bool { self.is_negative } + #[inline] fn is_positive(&self) -> bool { !self.is_negative } + #[inline] fn is_zero(&self) -> bool { self.value == 0 } + #[inline] fn abs(&self) -> Self { Self { is_negative: false, @@ -39,6 +44,7 @@ } } + #[inline] fn round(&self) -> i64 { if self.is_negative { -((self.value >> 32) as i64) @@ -47,6 +53,7 @@ } } + #[inline] fn sqr(&self) -> Self { Self { is_negative: false, @@ -111,6 +118,7 @@ } impl PartialEq for FPNum { + #[inline] fn eq(&self, other: &Self) -> bool { self.value == other.value && (self.is_negative == other.is_negative || self.value == 0) } @@ -119,6 +127,7 @@ impl Eq for FPNum {} impl PartialOrd for FPNum { + #[inline] fn partial_cmp(&self, rhs: &Self) -> std::option::Option { Some(self.cmp(rhs)) }