From 515978d1bd3a4256903a48a47da7df19283c33e2 Mon Sep 17 00:00:00 2001 From: Flavio Percoco Date: Wed, 15 Jan 2014 17:42:23 +0100 Subject: [PATCH] Use the least significant beat to determine if int/uint is even --- src/libstd/num/int_macros.rs | 2 +- src/libstd/num/uint_macros.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libstd/num/int_macros.rs b/src/libstd/num/int_macros.rs index 0e7e4277dd6cd..8e48fcf587213 100644 --- a/src/libstd/num/int_macros.rs +++ b/src/libstd/num/int_macros.rs @@ -308,7 +308,7 @@ impl Integer for $T { /// Returns `true` if the number is divisible by `2` #[inline] - fn is_even(&self) -> bool { self.is_multiple_of(&2) } + fn is_even(&self) -> bool { self & 1 == 0 } /// Returns `true` if the number is not divisible by `2` #[inline] diff --git a/src/libstd/num/uint_macros.rs b/src/libstd/num/uint_macros.rs index 1a256981d74ee..852fc5016b017 100644 --- a/src/libstd/num/uint_macros.rs +++ b/src/libstd/num/uint_macros.rs @@ -169,7 +169,7 @@ impl Integer for $T { /// Returns `true` if the number is divisible by `2` #[inline] - fn is_even(&self) -> bool { self.is_multiple_of(&2) } + fn is_even(&self) -> bool { self & 1 == 0 } /// Returns `true` if the number is not divisible by `2` #[inline]