diff --git a/src/bin/ponderosa-cpu.rs b/src/bin/ponderosa-cpu.rs index 3c178fc..b035b6d 100644 --- a/src/bin/ponderosa-cpu.rs +++ b/src/bin/ponderosa-cpu.rs @@ -66,13 +66,7 @@ fn parse_rom(path: &String) -> io::Result<(state::Land, Vec, HashMa } println!("World\n====="); - - for y in (0..land.height).rev() { - for x in 0..land.width { - print!("{}\t", land.map.get(&(x, y)).unwrap_or(&0u16)); - } - println!(); - } + dbg!(&land); rom_words.pop_front().unwrap(); // null-word delimiter @@ -227,13 +221,7 @@ fn main() -> io::Result<()> { } println!("Resulting World\n====="); - - for y in (0..land.height).rev() { - for x in 0..land.width { - print!("{}\t", land.map.get(&(x, y)).unwrap_or(&0u16)); - } - println!(); - } + dbg!(land); Ok(()) } diff --git a/src/state.rs b/src/state.rs index 5f39a8c..05248fe 100644 --- a/src/state.rs +++ b/src/state.rs @@ -92,6 +92,21 @@ impl Land { } } +impl std::fmt::Debug for Land { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + let mut built_string = "\n".to_owned(); + + for y in (0..self.height).rev() { + for x in 0..self.width { + built_string.push_str(&format!("{}\t", self.map.get(&(x, y)).unwrap_or(&0u16))); + } + built_string.push_str("\n"); + } + + write!(f, "{}", built_string) + } +} + pub type Rule = VecDeque; pub struct Tree {