[−][src]Trait rusty_boy_advance::utils::AsBoolSlice
Utility impl on u8's for some kind of "bit pattern matching".
Consider performance implications (If any) later.
Examples
use rusty_boy_advance::utils::AsBoolSlice; fn disassemble(x: u8) -> Option<&'static str> { const T: bool = true; const F: bool = false; match x.as_bools() { [T, T, T, _, _, _, _, _] => Some("First three bits set"), [_, _, F, _, _, _, _, _] => Some("Third bit not set"), _ => None, } } assert!(disassemble(0b1110_0000u8) == Some("First three bits set")); assert!(disassemble(0b1110_1100u8) == Some("First three bits set")); assert!(disassemble(0b1100_1100u8) == Some("Third bit not set")); assert!(disassemble(0b0000_1100u8) == Some("Third bit not set")); assert!(disassemble(0b0010_1100u8) == None);