Improve list display
This commit is contained in:
parent
799875a55d
commit
a8ed942c13
@ -1,5 +1,6 @@
|
|||||||
use std::{
|
use std::{
|
||||||
cmp::Ordering,
|
cmp::Ordering,
|
||||||
|
fmt::{self, Display, Formatter},
|
||||||
sync::{Arc, RwLock, RwLockReadGuard, RwLockWriteGuard},
|
sync::{Arc, RwLock, RwLockReadGuard, RwLockWriteGuard},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -61,3 +62,21 @@ impl PartialOrd for List {
|
|||||||
Some(self.cmp(other))
|
Some(self.cmp(other))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Display for List {
|
||||||
|
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||||
|
let items = self.items();
|
||||||
|
|
||||||
|
write!(f, "[")?;
|
||||||
|
|
||||||
|
for (index, value) in items.iter().enumerate() {
|
||||||
|
write!(f, "{value}")?;
|
||||||
|
|
||||||
|
if index != items.len() - 1 {
|
||||||
|
write!(f, ", ")?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
write!(f, "]")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -489,13 +489,7 @@ impl Display for Value {
|
|||||||
write!(f, "none")
|
write!(f, "none")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Value::List(list) => {
|
Value::List(list) => write!(f, "{list}"),
|
||||||
write!(f, "[")?;
|
|
||||||
for value in list.items().iter() {
|
|
||||||
write!(f, " {value} ")?;
|
|
||||||
}
|
|
||||||
write!(f, "]")
|
|
||||||
}
|
|
||||||
Value::Map(map) => write!(f, "{map}"),
|
Value::Map(map) => write!(f, "{map}"),
|
||||||
Value::Function(function) => write!(f, "{function}"),
|
Value::Function(function) => write!(f, "{function}"),
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user