Improve FnPtr debug print.

This commit is contained in:
Stephen Chung 2023-04-27 12:11:41 +08:00
parent 4ec16d14e0
commit ff2a23189a

View File

@ -49,16 +49,19 @@ impl fmt::Debug for FnPtr {
#[cold]
#[inline(never)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if self.is_curried() {
self.curry
.iter()
.fold(f.debug_tuple("Fn").field(&self.name), |f, curry| {
f.field(curry)
})
.finish()
} else {
write!(f, "Fn({})", self.fn_name())
let ff = &mut f.debug_tuple("Fn");
ff.field(&self.name);
self.curry.iter().for_each(|curry| {
ff.field(curry);
});
ff.finish()?;
#[cfg(not(feature = "no_function"))]
if let Some(ref fn_def) = self.fn_def {
write!(f, ": {fn_def}")?;
}
Ok(())
}
}