mirror of
https://github.com/nushell/nushell.git
synced 2025-01-22 14:18:55 +01:00
Merge pull request #125 from jonathandturner/tableview_force
now tableview forces being a table
This commit is contained in:
commit
cc1e7d2049
@ -13,13 +13,24 @@ pub struct TableView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl TableView {
|
impl TableView {
|
||||||
|
fn merge_descriptors(values: &[Value]) -> Vec<DataDescriptor> {
|
||||||
|
let mut ret = vec![];
|
||||||
|
for value in values {
|
||||||
|
for desc in value.data_descriptors() {
|
||||||
|
if !ret.contains(&desc) {
|
||||||
|
ret.push(desc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ret
|
||||||
|
}
|
||||||
|
|
||||||
pub fn from_list(values: &[Value]) -> Option<TableView> {
|
pub fn from_list(values: &[Value]) -> Option<TableView> {
|
||||||
if values.len() == 0 {
|
if values.len() == 0 {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let item = &values[0];
|
let headers = TableView::merge_descriptors(values);
|
||||||
let headers = item.data_descriptors();
|
|
||||||
|
|
||||||
if headers.len() == 0 {
|
if headers.len() == 0 {
|
||||||
return None;
|
return None;
|
||||||
|
Loading…
Reference in New Issue
Block a user