Skip to content

Commit e9c5618

Browse files
author
InAnYan
committed
Improvements
1 parent 0faaddb commit e9c5618

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

module/core/format_tools/src/format/output_format.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
mod private
3333
{
3434

35-
use std::borrow::Cow;
36-
3735
use crate::*;
3836
use print::
3937
{

module/core/format_tools/src/format/print.rs

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,26 +366,48 @@ mod private
366366
}
367367

368368
/// Extract input data from and collect it in a format consumable by output formatter.
369-
pub fn extract< 't, 'context, Table, RowKey, Row, CellKey>
369+
pub fn extract< 'context, Table, RowKey, Row, CellKey>
370370
(
371-
table : &'t Table,
371+
table : &'data Table,
372372
filter_col : &'context ( dyn FilterCol + 'context ),
373373
filter_row : &'context ( dyn FilterRow + 'context ),
374374
callback : impl for< 'a2 > FnOnce( &'a2 InputExtract< 'a2 > ) -> fmt::Result,
375375
)
376376
-> fmt::Result
377377
where
378-
'data : 't,
379-
// 't : 'data,
380378
Table : TableRows< RowKey = RowKey, Row = Row, CellKey = CellKey >,
381379
Table : TableHeader< CellKey = CellKey >,
382380
RowKey : table::RowKey,
383381
Row : Cells< CellKey > + 'data,
384382
CellKey : table::CellKey + ?Sized + 'data,
385383
// CellRepr : table::CellRepr,
386384
{
385+
let rows = table.rows().map( | r | r.cells().map( | ( _, c ) | {
386+
match c
387+
{
388+
Some( c ) => c,
389+
None => Cow::from( "" ),
390+
}
391+
}).collect()).collect();
392+
393+
let has_header = table.header().is_some();
394+
395+
let column_names = match table.header()
396+
{
397+
Some( header ) => header.map( | ( k, _ ) | Cow::from( k.borrow() ) ).collect(),
398+
399+
None => match table.rows().next()
400+
{
401+
Some( r ) => r.cells().map( | ( k, _ ) | Cow::from( k.borrow() ) ).collect(),
402+
None => Vec::new()
403+
}
404+
};
405+
387406
Self::extract_from_raw_table
388407
(
408+
column_names,
409+
has_header,
410+
rows,
389411
filter_col,
390412
filter_row,
391413
callback,

0 commit comments

Comments
 (0)