Playing with tables.

This commit is contained in:
Rhinemann 2023-06-28 00:10:53 +03:00
parent f522eab9bf
commit ed4a9f08cd
2 changed files with 18 additions and 3 deletions

View File

@ -13,4 +13,6 @@ panic = 'abort' # Abort on panic
strip = true # Strip symbols from binary*
[dependencies]
text_io = "0.1.12"
text_io = "0.1.12"
prettytable-rs = "0.10.0"
#tabled = "0.12.2"

View File

@ -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<Cell> = 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.
///