Prettier tree printing
parent
37fc1f1974
commit
a0ffc73333
25
src/util.rs
25
src/util.rs
|
@ -1,4 +1,7 @@
|
|||
use std::{fmt::Display, num::NonZeroU8};
|
||||
use std::{
|
||||
fmt::{Debug, Display},
|
||||
num::NonZeroU8,
|
||||
};
|
||||
|
||||
use termion::color::{self, Color};
|
||||
|
||||
|
@ -34,7 +37,7 @@ impl Display for Player {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Clone, Copy)]
|
||||
#[derive(PartialEq, Eq, Clone, Copy, Hash)]
|
||||
pub enum Symb {
|
||||
Number(NonZeroU8),
|
||||
Zero,
|
||||
|
@ -47,13 +50,19 @@ pub enum Symb {
|
|||
impl Display for Symb {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::Number(x) => x.fmt(f),
|
||||
Self::Zero => '0'.fmt(f),
|
||||
Self::Plus => '+'.fmt(f),
|
||||
Self::Minus => '-'.fmt(f),
|
||||
Self::Div => '÷'.fmt(f),
|
||||
Self::Times => '×'.fmt(f),
|
||||
Self::Number(x) => write!(f, "{x}")?,
|
||||
Self::Zero => write!(f, "0")?,
|
||||
Self::Plus => write!(f, "+")?,
|
||||
Self::Minus => write!(f, "-")?,
|
||||
Self::Div => write!(f, "÷")?,
|
||||
Self::Times => write!(f, "×")?,
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
impl Debug for Symb {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
Display::fmt(self, f)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue