Implement Display for ddr::ssq::Row
This makes debugging easier
This commit is contained in:
parent
60b74c7e97
commit
dc27f999c5
|
@ -59,6 +59,19 @@ impl Into<Vec<bool>> for PlayerRow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for PlayerRow {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
write!(
|
||||||
|
f,
|
||||||
|
"{}{}{}{}",
|
||||||
|
if self.left { "←" } else { " " },
|
||||||
|
if self.down { "↓" } else { " " },
|
||||||
|
if self.up { "↑" } else { " " },
|
||||||
|
if self.right { "→" } else { " " },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub enum Row {
|
pub enum Row {
|
||||||
Single(PlayerRow),
|
Single(PlayerRow),
|
||||||
|
@ -79,6 +92,16 @@ impl Into<Vec<bool>> for Row {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for Row {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
let player_rows = match self {
|
||||||
|
Self::Single(player_row) => vec![player_row],
|
||||||
|
Self::Double(player_row1, player_row2) => vec![player_row1, player_row2],
|
||||||
|
};
|
||||||
|
write!(f, "{}", utils::join_display_values(player_rows, " "))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Row {
|
impl Row {
|
||||||
fn new(byte: u8, players: u8) -> Self {
|
fn new(byte: u8, players: u8) -> Self {
|
||||||
match players {
|
match players {
|
||||||
|
|
Reference in a new issue