feat: implement debug trait for land

This commit is contained in:
Nat 2024-12-17 16:42:59 -08:00
parent 6bec93765a
commit db7df4da37
2 changed files with 17 additions and 14 deletions

View File

@ -66,13 +66,7 @@ fn parse_rom(path: &String) -> io::Result<(state::Land, Vec<state::Rule>, 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(())
}

View File

@ -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<u16>;
pub struct Tree {