diff options
| author | bors <bors@rust-lang.org> | 2014-01-15 16:02:01 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-01-15 16:02:01 -0800 |
| commit | 36971217aa64b6fc5f543f2620e488d16e67b1f4 (patch) | |
| tree | 98bb8bed0e13d793c1291460c56416a731de68a3 /src/libstd | |
| parent | 149fc76698318f8f7cdfaa37a818e347721764e7 (diff) | |
| parent | 515978d1bd3a4256903a48a47da7df19283c33e2 (diff) | |
| download | rust-36971217aa64b6fc5f543f2620e488d16e67b1f4.tar.gz rust-36971217aa64b6fc5f543f2620e488d16e67b1f4.zip | |
auto merge of #11568 : FlaPer87/rust/even, r=alexcrichton
This implementation should be a bit more optimal than calling `self.is_multiple_of(&2)`
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/num/int_macros.rs | 2 | ||||
| -rw-r--r-- | 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 0e7e4277dd6..8e48fcf5872 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 1a256981d74..852fc5016b0 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] |
