Simplify some expressions by using the assign op pattern.

See also https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#assign_op_pattern
This commit is contained in:
Stefano Probst 2018-10-30 12:40:41 +01:00
parent 7df3f75934
commit 8239b298cb
2 changed files with 11 additions and 11 deletions

View File

@ -448,7 +448,7 @@ impl CPU {
fn shift_right_with_flags(p_val: &mut u8, status: &mut Status) {
let mask = 1;
let is_bit_0_set = (*p_val & mask) == mask;
*p_val = *p_val >> 1;
*p_val >>= 1;
status.set_with_mask(
PS_CARRY,
Status::new(StatusArgs {

View File

@ -100,39 +100,39 @@ impl Status {
let mut out = Status::empty();
if negative {
out = out | PS_NEGATIVE
out |= PS_NEGATIVE
}
if overflow {
out = out | PS_OVERFLOW
out |= PS_OVERFLOW
}
if unused {
out = out | PS_UNUSED
out |= PS_UNUSED
}
if brk {
out = out | PS_BRK
out |= PS_BRK
}
if decimal_mode {
out = out | PS_DECIMAL_MODE
out |= PS_DECIMAL_MODE
}
if disable_interrupts {
out = out | PS_DISABLE_INTERRUPTS
out |= PS_DISABLE_INTERRUPTS
}
if zero {
out = out | PS_ZERO
out |= PS_ZERO
}
if carry {
out = out | PS_CARRY
out |= PS_CARRY
}
out
}
pub fn and(&mut self, rhs: Status) {
*self = *self & rhs;
*self &= rhs;
}
pub fn or(&mut self, rhs: Status) {
*self = *self | rhs;
*self |= rhs;
}
pub fn set_with_mask(&mut self, mask: Status, rhs: Status) {