From ed4a9f08cd23717f5cd22e7c0990924ca7c3eb3b Mon Sep 17 00:00:00 2001 From: Rhinemann Date: Wed, 28 Jun 2023 00:10:53 +0300 Subject: [PATCH] Playing with tables. --- Cargo.toml | 4 +++- src/bit_utilities.rs | 17 +++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8e99260..f30fd3f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,4 +13,6 @@ panic = 'abort' # Abort on panic strip = true # Strip symbols from binary* [dependencies] -text_io = "0.1.12" \ No newline at end of file +text_io = "0.1.12" +prettytable-rs = "0.10.0" +#tabled = "0.12.2" \ No newline at end of file diff --git a/src/bit_utilities.rs b/src/bit_utilities.rs index b017688..77eae5f 100644 --- a/src/bit_utilities.rs +++ b/src/bit_utilities.rs @@ -1,3 +1,4 @@ +use prettytable::{Cell, Row, Table}; use std::collections::VecDeque; use std::{cmp, fmt}; @@ -86,6 +87,18 @@ impl BasicRegister { pub fn len(&self) -> usize { self.memory.len() } + + /*pub fn table(&self) -> Table { + let mut table = Table::new(); + + let mut memory_row: Vec = vec![Cell::new("Memory")]; + self.memory + .iter() + .for_each(|value| memory_row.push(Cell::new((*value as u8).to_string().as_str()))); + + table.add_row(Row::new(memory_row)); + table + }*/ } impl Default for BasicRegister { @@ -111,7 +124,7 @@ impl fmt::Display for BasicRegister { } } -impl fmt::Binary for BasicRegister { +/*impl fmt::Binary for BasicRegister { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "Memory: ")?; @@ -121,7 +134,7 @@ impl fmt::Binary for BasicRegister { write!(f, "") } -} +}*/ /// Converts a u8 number to a boolean. ///