Skip to content

Commit

Permalink
Better handling of empty tables
Browse files Browse the repository at this point in the history
  • Loading branch information
devashishdxt committed Jan 29, 2021
1 parent 4fc1a25 commit 3d3d1fc
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions cli-table/src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ impl TableStruct {
}

fn required_dimension(&self) -> Dimension {
if self.rows.is_empty() {
return Default::default();
}

let mut heights = Vec::with_capacity(self.rows.len() + 1);

let row_dimension = match self.title {
Expand Down Expand Up @@ -106,9 +102,7 @@ impl TableStruct {
)?;

if let Some(ref title) = self.title {
let title_dimension = row_dimensions
.next()
.unwrap_or_else(|| title.required_dimension());
let title_dimension = row_dimensions.next().unwrap();
title.print_writer(&writer, title_dimension, &self.format, &color_spec)?;

if self.format.separator.title.is_some() {
Expand Down

0 comments on commit 3d3d1fc

Please sign in to comment.