feat: implement debug trait for land
This commit is contained in:
parent
6bec93765a
commit
db7df4da37
|
@ -66,13 +66,7 @@ fn parse_rom(path: &String) -> io::Result<(state::Land, Vec<state::Rule>, HashMa
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("World\n=====");
|
println!("World\n=====");
|
||||||
|
dbg!(&land);
|
||||||
for y in (0..land.height).rev() {
|
|
||||||
for x in 0..land.width {
|
|
||||||
print!("{}\t", land.map.get(&(x, y)).unwrap_or(&0u16));
|
|
||||||
}
|
|
||||||
println!();
|
|
||||||
}
|
|
||||||
|
|
||||||
rom_words.pop_front().unwrap(); // null-word delimiter
|
rom_words.pop_front().unwrap(); // null-word delimiter
|
||||||
|
|
||||||
|
@ -227,13 +221,7 @@ fn main() -> io::Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("Resulting World\n=====");
|
println!("Resulting World\n=====");
|
||||||
|
dbg!(land);
|
||||||
for y in (0..land.height).rev() {
|
|
||||||
for x in 0..land.width {
|
|
||||||
print!("{}\t", land.map.get(&(x, y)).unwrap_or(&0u16));
|
|
||||||
}
|
|
||||||
println!();
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
15
src/state.rs
15
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<u16>;
|
pub type Rule = VecDeque<u16>;
|
||||||
|
|
||||||
pub struct Tree {
|
pub struct Tree {
|
||||||
|
|
Loading…
Reference in New Issue