|
@@ -26,13 +26,12 @@ struct Board {
|
|
|
26
|
-
fn fmt(&self, f: &mut fmt::Formatter<'_>)
|
|
26
|
+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
27
|
-
-> fmt::Result {
|
|
28
27
|
for row in &self.cells {
|
|
29
|
-
|
|
28
|
+
for col in row {
|
|
30
|
-
|
|
29
|
+
write!(f, " {} ", col)?;
|
|
31
|
-
|
|
30
|
+
}
|
|
32
|
-
|
|
31
|
+
write!(f, "\n")?;
|
|
33
32
|
}
|
|
34
33
|
Ok(())
|
|
35
34
|
}
|
|
@@ -65,7 +64,10 @@ impl Board {
|
|
|
65
64
|
rows.chain(columns)
|
|
66
65
|
.chain(diags)
|
|
67
66
|
.map(|triple| {
|
|
67
|
+
triple
|
|
68
|
+
.iter()
|
|
69
|
+
.map(|&i| self.get_state(i))
|
|
68
|
-
|
|
70
|
+
.fold(true, |acc, x| acc && x == target)
|
|
69
71
|
})
|
|
70
72
|
.any(id)
|