auto merge of #11568 : FlaPer87/rust/even, r=alexcrichton
This implementation should be a bit more optimal than calling `self.is_multiple_of(&2)`
This commit is contained in:
commit
36971217aa
@ -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]
|
||||
|
@ -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]
|
||||
|
Loading…
x
Reference in New Issue
Block a user