diff options
Diffstat (limited to 'src/libstd/num')
| -rw-r--r-- | src/libstd/num/f32.rs | 36 | ||||
| -rw-r--r-- | src/libstd/num/f64.rs | 36 | ||||
| -rw-r--r-- | src/libstd/num/uint_macros.rs | 10 |
3 files changed, 41 insertions, 41 deletions
diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs index 1bb488d0278..2787e028645 100644 --- a/src/libstd/num/f32.rs +++ b/src/libstd/num/f32.rs @@ -206,35 +206,35 @@ impl Orderable for f32 { /// Returns `NaN` if either of the numbers are `NaN`. #[inline] fn min(&self, other: &f32) -> f32 { - cond!( - (self.is_NaN()) { *self } - (other.is_NaN()) { *other } - (*self < *other) { *self } - _ { *other } - ) + match () { + _ if self.is_NaN() => *self, + _ if other.is_NaN() => *other, + _ if *self < *other => *self, + _ => *other, + } } /// Returns `NaN` if either of the numbers are `NaN`. #[inline] fn max(&self, other: &f32) -> f32 { - cond!( - (self.is_NaN()) { *self } - (other.is_NaN()) { *other } - (*self > *other) { *self } - _ { *other } - ) + match () { + _ if self.is_NaN() => *self, + _ if other.is_NaN() => *other, + _ if *self > *other => *self, + _ => *other, + } } /// Returns the number constrained within the range `mn <= self <= mx`. /// If any of the numbers are `NaN` then `NaN` is returned. #[inline] fn clamp(&self, mn: &f32, mx: &f32) -> f32 { - cond!( - (self.is_NaN()) { *self } - (!(*self <= *mx)) { *mx } - (!(*self >= *mn)) { *mn } - _ { *self } - ) + match () { + _ if self.is_NaN() => *self, + _ if !(*self <= *mx) => *mx, + _ if !(*self >= *mn) => *mn, + _ => *self, + } } } diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs index 604eac0a0a7..afc22ec212b 100644 --- a/src/libstd/num/f64.rs +++ b/src/libstd/num/f64.rs @@ -229,35 +229,35 @@ impl Orderable for f64 { /// Returns `NaN` if either of the numbers are `NaN`. #[inline] fn min(&self, other: &f64) -> f64 { - cond!( - (self.is_NaN()) { *self } - (other.is_NaN()) { *other } - (*self < *other) { *self } - _ { *other } - ) + match () { + _ if self.is_NaN() => *self, + _ if other.is_NaN() => *other, + _ if *self < *other => *self, + _ => *other, + } } /// Returns `NaN` if either of the numbers are `NaN`. #[inline] fn max(&self, other: &f64) -> f64 { - cond!( - (self.is_NaN()) { *self } - (other.is_NaN()) { *other } - (*self > *other) { *self } - _ { *other } - ) + match () { + _ if self.is_NaN() => *self, + _ if other.is_NaN() => *other, + _ if *self > *other => *self, + _ => *other, + } } /// Returns the number constrained within the range `mn <= self <= mx`. /// If any of the numbers are `NaN` then `NaN` is returned. #[inline] fn clamp(&self, mn: &f64, mx: &f64) -> f64 { - cond!( - (self.is_NaN()) { *self } - (!(*self <= *mx)) { *mx } - (!(*self >= *mn)) { *mn } - _ { *self } - ) + match () { + _ if self.is_NaN() => *self, + _ if !(*self <= *mx) => *mx, + _ if !(*self >= *mn) => *mn, + _ => *self, + } } } diff --git a/src/libstd/num/uint_macros.rs b/src/libstd/num/uint_macros.rs index 0a9c912a6e2..7cd1be7ab74 100644 --- a/src/libstd/num/uint_macros.rs +++ b/src/libstd/num/uint_macros.rs @@ -70,11 +70,11 @@ impl Orderable for $T { /// Returns the number constrained within the range `mn <= self <= mx`. #[inline] fn clamp(&self, mn: &$T, mx: &$T) -> $T { - cond!( - (*self > *mx) { *mx } - (*self < *mn) { *mn } - _ { *self } - ) + match () { + _ if (*self > *mx) => *mx, + _ if (*self < *mn) => *mn, + _ => *self, + } } } |
