Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit 0e026f3

Browse files
committed
Fix hex float trait recursion problem
1 parent 41d2216 commit 0e026f3

File tree

1 file changed

+5
-25
lines changed

1 file changed

+5
-25
lines changed

libm/src/math/support/hex_float.rs

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -245,29 +245,21 @@ fn fmt_any_hex<F: Float>(x: &F, f: &mut fmt::Formatter<'_>) -> fmt::Result {
245245
write!(f, "0x{leading}{sig:0mwidth$x}p{exponent:+}")
246246
}
247247

248-
#[cfg(f16_enabled)]
249-
impl fmt::LowerHex for Hexf<f16> {
248+
impl<F: Float> fmt::LowerHex for Hexf<F> {
250249
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
251250
fmt_any_hex(&self.0, f)
252251
}
253252
}
254253

255-
impl fmt::LowerHex for Hexf<f32> {
254+
impl<F: Float> fmt::LowerHex for Hexf<(F, F)> {
256255
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
257-
fmt_any_hex(&self.0, f)
258-
}
259-
}
260-
261-
impl fmt::LowerHex for Hexf<f64> {
262-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
263-
fmt_any_hex(&self.0, f)
256+
write!(f, "({:x}, {:x})", Hexf(self.0.0), Hexf(self.0.1))
264257
}
265258
}
266259

267-
#[cfg(f128_enabled)]
268-
impl fmt::LowerHex for Hexf<f128> {
260+
impl<F: Float> fmt::LowerHex for Hexf<(F, i32)> {
269261
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
270-
fmt_any_hex(&self.0, f)
262+
write!(f, "({:x}, {:x})", Hexf(self.0.0), Hexf(self.0.1))
271263
}
272264
}
273265

@@ -277,18 +269,6 @@ impl fmt::LowerHex for Hexf<i32> {
277269
}
278270
}
279271

280-
impl<T1, T2> fmt::LowerHex for Hexf<(T1, T2)>
281-
where
282-
T1: Copy,
283-
T2: Copy,
284-
Hexf<T1>: fmt::LowerHex,
285-
Hexf<T2>: fmt::LowerHex,
286-
{
287-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
288-
write!(f, "({:x}, {:x})", Hexf(self.0.0), Hexf(self.0.1))
289-
}
290-
}
291-
292272
impl<T> fmt::Debug for Hexf<T>
293273
where
294274
Hexf<T>: fmt::LowerHex,

0 commit comments

Comments
 (0)