Display type name when printing Dynamic values that have no built-in format.
This commit is contained in:
parent
e8b6d0143d
commit
ec3074106e
14
src/any.rs
14
src/any.rs
@ -243,12 +243,15 @@ impl fmt::Display for Dynamic {
|
||||
#[cfg(not(feature = "no_index"))]
|
||||
Union::Array(value) => fmt::Debug::fmt(value, f),
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
Union::Map(value) => write!(f, "#{:?}", value),
|
||||
Union::Map(value) => {
|
||||
f.write_str("#")?;
|
||||
fmt::Debug::fmt(value, f)
|
||||
}
|
||||
Union::FnPtr(value) => fmt::Display::fmt(value, f),
|
||||
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
Union::Variant(value) if value.is::<Instant>() => write!(f, "<timestamp>"),
|
||||
Union::Variant(_) => write!(f, "?"),
|
||||
Union::Variant(value) => write!(f, "{}", (*value).type_name()),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -266,12 +269,15 @@ impl fmt::Debug for Dynamic {
|
||||
#[cfg(not(feature = "no_index"))]
|
||||
Union::Array(value) => fmt::Debug::fmt(value, f),
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
Union::Map(value) => write!(f, "#{:?}", value),
|
||||
Union::Map(value) => {
|
||||
f.write_str("#")?;
|
||||
fmt::Debug::fmt(value, f)
|
||||
}
|
||||
Union::FnPtr(value) => fmt::Display::fmt(value, f),
|
||||
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
Union::Variant(value) if value.is::<Instant>() => write!(f, "<timestamp>"),
|
||||
Union::Variant(_) => write!(f, "<dynamic>"),
|
||||
Union::Variant(value) => write!(f, "{}", (*value).type_name()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user