Merge pull request #125 from jonathandturner/tableview_force

now tableview forces being a table
This commit is contained in:
Jonathan Turner 2019-06-21 20:04:06 +12:00 committed by GitHub
commit cc1e7d2049
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;