in rhai/src/types/dynamic.rs [524:623]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.0 {
Union::Unit(ref v, ..) => fmt::Debug::fmt(v, f),
Union::Bool(ref v, ..) => fmt::Debug::fmt(v, f),
Union::Str(ref v, ..) => fmt::Debug::fmt(v, f),
Union::Char(ref v, ..) => fmt::Debug::fmt(v, f),
Union::Int(ref v, ..) => fmt::Debug::fmt(v, f),
#[cfg(not(feature = "no_float"))]
Union::Float(ref v, ..) => fmt::Debug::fmt(v, f),
#[cfg(feature = "decimal")]
Union::Decimal(ref v, ..) => fmt::Debug::fmt(v, f),
#[cfg(not(feature = "no_index"))]
Union::Array(ref v, ..) => fmt::Debug::fmt(v, f),
#[cfg(not(feature = "no_index"))]
Union::Blob(ref v, ..) => {
f.write_str("[")?;
v.iter().enumerate().try_for_each(|(i, v)| {
if i > 0 && i % 8 == 0 {
f.write_str(" ")?;
}
write!(f, "{v:02x}")
})?;
f.write_str("]")
}
#[cfg(not(feature = "no_object"))]
Union::Map(ref v, ..) => {
f.write_str("#")?;
fmt::Debug::fmt(v, f)
}
Union::FnPtr(ref v, ..) => fmt::Debug::fmt(v, f),
#[cfg(not(feature = "no_time"))]
Union::TimeStamp(..) => write!(f, "<timestamp>"),
Union::Variant(ref v, ..) => {
let _value_any = (***v).as_any();
let _type_id = _value_any.type_id();
#[cfg(not(feature = "only_i32"))]
#[cfg(not(feature = "only_i64"))]
if let Some(value) = _value_any.downcast_ref::<u8>() {
return fmt::Debug::fmt(value, f);
} else if let Some(value) = _value_any.downcast_ref::<u16>() {
return fmt::Debug::fmt(value, f);
} else if let Some(value) = _value_any.downcast_ref::<u32>() {
return fmt::Debug::fmt(value, f);
} else if let Some(value) = _value_any.downcast_ref::<u64>() {
return fmt::Debug::fmt(value, f);
} else if let Some(value) = _value_any.downcast_ref::<i8>() {
return fmt::Debug::fmt(value, f);
} else if let Some(value) = _value_any.downcast_ref::<i16>() {
return fmt::Debug::fmt(value, f);
} else if let Some(value) = _value_any.downcast_ref::<i32>() {
return fmt::Debug::fmt(value, f);
} else if let Some(value) = _value_any.downcast_ref::<i64>() {
return fmt::Debug::fmt(value, f);
}
#[cfg(not(feature = "no_float"))]
#[cfg(not(feature = "f32_float"))]
if let Some(value) = _value_any.downcast_ref::<f32>() {
return fmt::Debug::fmt(value, f);
}
#[cfg(not(feature = "no_float"))]
#[cfg(feature = "f32_float")]
if let Some(value) = _value_any.downcast_ref::<f64>() {
return fmt::Debug::fmt(value, f);
}
#[cfg(not(feature = "only_i32"))]
#[cfg(not(feature = "only_i64"))]
#[cfg(not(target_family = "wasm"))]
if let Some(value) = _value_any.downcast_ref::<u128>() {
return fmt::Debug::fmt(value, f);
} else if let Some(value) = _value_any.downcast_ref::<i128>() {
return fmt::Debug::fmt(value, f);
}
if let Some(range) = _value_any.downcast_ref::<ExclusiveRange>() {
return write!(f, "{}..{}", range.start, range.end);
} else if let Some(range) = _value_any.downcast_ref::<InclusiveRange>() {
return write!(f, "{}..={}", range.start(), range.end());
}
f.write_str((***v).type_name())
}
#[cfg(not(feature = "no_closure"))]
#[cfg(not(feature = "sync"))]
Union::Shared(ref cell, ..) => {
if let Ok(v) = cell.try_borrow() {
write!(f, "{:?} (shared)", *v)
} else {
f.write_str("<shared>")
}
}
#[cfg(not(feature = "no_closure"))]
#[cfg(feature = "sync")]
Union::Shared(ref cell, ..) => fmt::Debug::fmt(&*cell.read().unwrap(), f),
}
}