1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use crate::square::Maze2D;
use std::fmt::{Debug, Display, Formatter};

impl Debug for Maze2D {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        f.debug_struct("Maze2D")
            .field("width", &self.config.width)
            .field("height", &self.config.height)
            .field("joints", &self.joints)
            .finish()
    }
}

impl Display for Maze2D {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        let matrix = self.matrix01();
        for line in matrix.rows(false) {
            for (_, _, point) in line {
                if *point {
                    write!(f, "■")?;
                }
                else {
                    write!(f, "□")?;
                }
            }
            writeln!(f)?;
        }
        Ok(())
    }
}