Better debug formatting for StaticVec.
This commit is contained in:
parent
8f55a15ab0
commit
e4cca7620f
30
src/any.rs
30
src/any.rs
@ -202,17 +202,17 @@ impl fmt::Display for Dynamic {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match &self.0 {
|
||||
Union::Unit(_) => write!(f, ""),
|
||||
Union::Bool(value) => write!(f, "{}", value),
|
||||
Union::Str(value) => write!(f, "{}", value),
|
||||
Union::Char(value) => write!(f, "{}", value),
|
||||
Union::Int(value) => write!(f, "{}", value),
|
||||
Union::Bool(value) => fmt::Display::fmt(value, f),
|
||||
Union::Str(value) => fmt::Display::fmt(value, f),
|
||||
Union::Char(value) => fmt::Display::fmt(value, f),
|
||||
Union::Int(value) => fmt::Display::fmt(value, f),
|
||||
#[cfg(not(feature = "no_float"))]
|
||||
Union::Float(value) => write!(f, "{}", value),
|
||||
Union::Float(value) => fmt::Display::fmt(value, f),
|
||||
#[cfg(not(feature = "no_index"))]
|
||||
Union::Array(value) => write!(f, "{:?}", value),
|
||||
Union::Array(value) => fmt::Debug::fmt(value, f),
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
Union::Map(value) => write!(f, "#{:?}", value),
|
||||
Union::Module(value) => write!(f, "{:?}", value),
|
||||
Union::Module(value) => fmt::Debug::fmt(value, f),
|
||||
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
Union::Variant(value) if value.is::<Instant>() => write!(f, "<timestamp>"),
|
||||
@ -224,18 +224,18 @@ impl fmt::Display for Dynamic {
|
||||
impl fmt::Debug for Dynamic {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match &self.0 {
|
||||
Union::Unit(value) => write!(f, "{:?}", value),
|
||||
Union::Bool(value) => write!(f, "{:?}", value),
|
||||
Union::Str(value) => write!(f, "{:?}", value),
|
||||
Union::Char(value) => write!(f, "{:?}", value),
|
||||
Union::Int(value) => write!(f, "{:?}", value),
|
||||
Union::Unit(value) => fmt::Debug::fmt(value, f),
|
||||
Union::Bool(value) => fmt::Debug::fmt(value, f),
|
||||
Union::Str(value) => fmt::Debug::fmt(value, f),
|
||||
Union::Char(value) => fmt::Debug::fmt(value, f),
|
||||
Union::Int(value) => fmt::Debug::fmt(value, f),
|
||||
#[cfg(not(feature = "no_float"))]
|
||||
Union::Float(value) => write!(f, "{:?}", value),
|
||||
Union::Float(value) => fmt::Debug::fmt(value, f),
|
||||
#[cfg(not(feature = "no_index"))]
|
||||
Union::Array(value) => write!(f, "{:?}", value),
|
||||
Union::Array(value) => fmt::Debug::fmt(value, f),
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
Union::Map(value) => write!(f, "#{:?}", value),
|
||||
Union::Module(value) => write!(f, "{:?}", value),
|
||||
Union::Module(value) => fmt::Debug::fmt(value, f),
|
||||
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
Union::Variant(value) if value.is::<Instant>() => write!(f, "<timestamp>"),
|
||||
|
@ -82,7 +82,7 @@ impl fmt::Debug for CallableFunction {
|
||||
Self::Pure(_) => write!(f, "NativePureFunction"),
|
||||
Self::Method(_) => write!(f, "NativeMethod"),
|
||||
Self::Iterator(_) => write!(f, "NativeIterator"),
|
||||
Self::Script(fn_def) => write!(f, "{:?}", fn_def),
|
||||
Self::Script(fn_def) => fmt::Debug::fmt(fn_def, f),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ impl fmt::Debug for Module {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"<module {:?}, functions={}>",
|
||||
"<module vars={:?}, functions={}>",
|
||||
self.variables,
|
||||
self.functions.len(),
|
||||
)
|
||||
|
@ -542,9 +542,7 @@ impl<T: Default> StaticVec<T> {
|
||||
|
||||
impl<T: fmt::Debug> fmt::Debug for StaticVec<T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "[ ")?;
|
||||
self.iter().try_for_each(|v| write!(f, "{:?}, ", v))?;
|
||||
write!(f, "]")
|
||||
fmt::Debug::fmt(&self.iter().collect::<Vec<_>>(), f)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user