From 8239b298cbaf44e9f1120d0f9a9ea8bed105ea1e Mon Sep 17 00:00:00 2001 From: Stefano Probst Date: Tue, 30 Oct 2018 12:40:41 +0100 Subject: [PATCH] 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 --- src/cpu.rs | 2 +- src/registers.rs | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/cpu.rs b/src/cpu.rs index d925519..4028e2b 100644 --- a/src/cpu.rs +++ b/src/cpu.rs @@ -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 { diff --git a/src/registers.rs b/src/registers.rs index 50108bb..485e923 100644 --- a/src/registers.rs +++ b/src/registers.rs @@ -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) {