Closed leopnt closed 2 years ago
At the end of 3.1, maybe you could give a hint to use wrapping_add(). Because rust doesn't allow overflow in debug mode:
wrapping_add()
fn inx(&mut self) { self.rx = self.rx.wrapping_add(1) as u8; }
instead of:
fn inx(&mut self) { self.rx += 1; }
to solve:
#[test] fn test_inx_overflow() { let mut cpu = CPU::new(); cpu.register_x = 0xff; cpu.interpret(vec![0xe8, 0xe8, 0x00]); assert_eq!(cpu.register_x, 1) }
Just seen you provided source code to each chapter, my bad
At the end of 3.1, maybe you could give a hint to use
wrapping_add()
. Because rust doesn't allow overflow in debug mode:instead of:
to solve: