From 31143cac1d5b065e868193cbfa49cd8cd06c69b4 Mon Sep 17 00:00:00 2001 From: Rhinemann Date: Mon, 26 Jun 2023 00:43:51 +0300 Subject: [PATCH] Implemented fmt::Binary. --- src/bit_utilities.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/bit_utilities.rs b/src/bit_utilities.rs index 3776a5b..aee3881 100644 --- a/src/bit_utilities.rs +++ b/src/bit_utilities.rs @@ -68,6 +68,18 @@ impl fmt::Display for BasicRegister { } } +impl fmt::Binary for BasicRegister { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + write!(f, "Memory: ")?; + + for v in self.memory.iter() { + write!(f, "{}", *v as u8)?; + } + + write!(f, "") + } +} + fn read_vec(variable_name: &str) -> Vec { loop { print!("Enter {variable_name}: ");