Add from_array and improve array viewing

This commit is contained in:
Jonathan Turner
2019-08-12 17:51:13 +12:00
parent 7c4a4ec62e
commit 3d5395fdd5
7 changed files with 54 additions and 8 deletions

View File

@ -40,11 +40,17 @@ impl TableView {
let mut entries = vec![];
for (idx, value) in values.iter().enumerate() {
let mut row: Vec<String> = headers
.iter()
.enumerate()
.map(|(i, d)| value.get_data(d).borrow().format_leaf(Some(&headers[i])))
.collect();
let mut row: Vec<String> = match value {
Tagged {
item: Value::Object(..),
..
} => headers
.iter()
.enumerate()
.map(|(i, d)| value.get_data(d).borrow().format_leaf(Some(&headers[i])))
.collect(),
x => vec![x.format_leaf(None)],
};
if values.len() > 1 {
row.insert(0, format!("{}", Color::Black.bold().paint(idx.to_string())));