[core] Implement Display for Score
This commit is contained in:
parent
80ac8ea036
commit
4e80cc36ca
1 changed files with 17 additions and 1 deletions
|
@ -1,6 +1,9 @@
|
||||||
// Eryn Wells <eryn@erynwells.me>
|
// Eryn Wells <eryn@erynwells.me>
|
||||||
|
|
||||||
use std::ops::{Add, AddAssign, Mul, Sub, SubAssign};
|
use std::{
|
||||||
|
fmt,
|
||||||
|
ops::{Add, AddAssign, Mul, Neg, Sub, SubAssign},
|
||||||
|
};
|
||||||
|
|
||||||
pub(crate) type ScoreInner = i32;
|
pub(crate) type ScoreInner = i32;
|
||||||
|
|
||||||
|
@ -69,3 +72,16 @@ impl From<ScoreInner> for Score {
|
||||||
Score(value)
|
Score(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for Score {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
let value = self.0;
|
||||||
|
if *self == Self::MAX {
|
||||||
|
write!(f, "INF")
|
||||||
|
} else if *self == Self::MIN {
|
||||||
|
write!(f, "-INF")
|
||||||
|
} else {
|
||||||
|
write!(f, "{value}cp")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue