Fix hex float trait recursion problem

This commit is contained in:
Trevor Gross 2025-01-30 12:52:35 +00:00
parent 8db5ff73e6
commit 98bee053ef

View file

@ -245,29 +245,21 @@ fn fmt_any_hex<F: Float>(x: &F, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "0x{leading}{sig:0mwidth$x}p{exponent:+}")
}
#[cfg(f16_enabled)]
impl fmt::LowerHex for Hexf<f16> {
impl<F: Float> fmt::LowerHex for Hexf<F> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt_any_hex(&self.0, f)
}
}
impl fmt::LowerHex for Hexf<f32> {
impl<F: Float> fmt::LowerHex for Hexf<(F, F)> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt_any_hex(&self.0, f)
write!(f, "({:x}, {:x})", Hexf(self.0.0), Hexf(self.0.1))
}
}
impl fmt::LowerHex for Hexf<f64> {
impl<F: Float> fmt::LowerHex for Hexf<(F, i32)> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt_any_hex(&self.0, f)
}
}
#[cfg(f128_enabled)]
impl fmt::LowerHex for Hexf<f128> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt_any_hex(&self.0, f)
write!(f, "({:x}, {:x})", Hexf(self.0.0), Hexf(self.0.1))
}
}
@ -277,18 +269,6 @@ impl fmt::LowerHex for Hexf<i32> {
}
}
impl<T1, T2> fmt::LowerHex for Hexf<(T1, T2)>
where
T1: Copy,
T2: Copy,
Hexf<T1>: fmt::LowerHex,
Hexf<T2>: fmt::LowerHex,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "({:x}, {:x})", Hexf(self.0.0), Hexf(self.0.1))
}
}
impl<T> fmt::Debug for Hexf<T>
where
Hexf<T>: fmt::LowerHex,