[core] Implement Display for Score

This commit is contained in:
Eryn Wells 2025-06-24 15:20:31 -07:00
parent 80ac8ea036
commit 4e80cc36ca

View file

@ -1,6 +1,9 @@
// 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;
@ -69,3 +72,16 @@ impl From<ScoreInner> for Score {
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")
}
}
}