impl Debug for Mat
This commit is contained in:
parent
1eee852191
commit
aee42c7ddf
|
@ -36,11 +36,13 @@ impl Mat {
|
||||||
|
|
||||||
pub const EMPTY: &'static Self = Self::new(&[]);
|
pub const EMPTY: &'static Self = Self::new(&[]);
|
||||||
|
|
||||||
|
#[inline]
|
||||||
const fn data(&self) -> &[u16] {
|
const fn data(&self) -> &[u16] {
|
||||||
unsafe { core::mem::transmute(self) }
|
&self.0
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the number of columns in the matrix. This always returns `COLUMNS`.
|
/// Returns the number of columns in the matrix. This always returns `COLUMNS`.
|
||||||
|
#[inline]
|
||||||
pub const fn cols(&self) -> i16 {
|
pub const fn cols(&self) -> i16 {
|
||||||
COLUMNS
|
COLUMNS
|
||||||
}
|
}
|
||||||
|
@ -73,6 +75,23 @@ impl Mat {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl core::fmt::Debug for Mat {
|
||||||
|
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||||
|
write!(f, "mat!{{")?;
|
||||||
|
let mut sep = "";
|
||||||
|
for y in (0..self.rows()).rev() {
|
||||||
|
write!(f, "{sep}\"")?;
|
||||||
|
for x in 0..self.cols() {
|
||||||
|
let occ = self.get(x, y);
|
||||||
|
f.write_str(if occ { "x" } else { "." })?;
|
||||||
|
}
|
||||||
|
write!(f, "\"")?;
|
||||||
|
sep = ";";
|
||||||
|
}
|
||||||
|
write!(f, "}}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "ascii", test))]
|
#[cfg(any(feature = "ascii", test))]
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub mod __ascii {
|
pub mod __ascii {
|
||||||
|
|
Loading…
Reference in New Issue