Compact BLOB display.

This commit is contained in:
Stephen Chung 2021-12-13 09:40:43 +08:00
parent 65529d28ef
commit 93e3c4c10a
2 changed files with 19 additions and 1 deletions

View File

@ -1,6 +1,15 @@
Rhai Release Notes Rhai Release Notes
================== ==================
Version 1.3.1
=============
Enhancements
------------
* `BLOB`'s are refined to display in a more compact hex format.
Version 1.3.0 Version 1.3.0
============= =============

View File

@ -689,7 +689,16 @@ impl fmt::Debug for Dynamic {
#[cfg(not(feature = "no_index"))] #[cfg(not(feature = "no_index"))]
Union::Array(ref value, _, _) => fmt::Debug::fmt(value, f), Union::Array(ref value, _, _) => fmt::Debug::fmt(value, f),
#[cfg(not(feature = "no_index"))] #[cfg(not(feature = "no_index"))]
Union::Blob(ref value, _, _) => fmt::Debug::fmt(value, f), Union::Blob(ref value, _, _) => {
f.write_str("[")?;
value.iter().enumerate().try_for_each(|(i, v)| {
if i > 0 && i % 8 == 0 {
f.write_str(" ")?;
}
write!(f, "{:02x}", v)
})?;
f.write_str("]")
}
#[cfg(not(feature = "no_object"))] #[cfg(not(feature = "no_object"))]
Union::Map(ref value, _, _) => { Union::Map(ref value, _, _) => {
f.write_str("#")?; f.write_str("#")?;