We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e0e4919 commit 88f5ca1Copy full SHA for 88f5ca1
src/grid/mod.rs
@@ -1,4 +1,8 @@
1
-use std::{io, ops::Deref};
+use std::{
2
+ fmt::{self, Display, Write},
3
+ io,
4
+ ops::Deref,
5
+};
6
7
#[derive(Debug)]
8
pub struct Grid {
@@ -129,6 +133,15 @@ impl Deref for Grid {
129
133
}
130
134
131
135
136
+impl Display for Grid {
137
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
138
+ self.grid.chunks_exact(self.width).try_for_each(|line| {
139
+ let buffer: String = line.iter().collect();
140
+ f.write_str(&buffer).and_then(|_| f.write_char('\n'))
141
+ })
142
+ }
143
+}
144
+
132
145
pub trait Neighbors: Iterator<Item = usize> {
146
fn north(&self) -> Option<usize>;
147
fn east(&self) -> Option<usize>;
0 commit comments