swf: Show scaled value in `swf::FixedN`'s `Debug` implementations

This commit is contained in:
Moulins 2024-01-19 14:24:42 +01:00 committed by TÖRÖK Attila
parent 379bed891f
commit 233478a273
1 changed files with 8 additions and 2 deletions

View File

@ -19,7 +19,7 @@ macro_rules! define_fixed {
into_float($($into_type:path),*) into_float($($into_type:path),*)
) => { ) => {
/// A signed fixed-point value with $frac_bits bits. /// A signed fixed-point value with $frac_bits bits.
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub struct $type_name($underlying_type); pub struct $type_name($underlying_type);
/// A signed fixed-point type. /// A signed fixed-point type.
@ -185,7 +185,13 @@ macro_rules! define_fixed {
impl std::fmt::Display for $type_name { impl std::fmt::Display for $type_name {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{}", self.to_f64()) std::fmt::Display::fmt(&self.to_f64(), f)
}
}
impl std::fmt::Debug for $type_name {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Debug::fmt(&self.to_f64(), f)
} }
} }