Skip to content

Panic in footer() with empty table #2

@gtunes-dev

Description

@gtunes-dev

Thank you for this crate!

footer() panics in the case where no rows have been written and borders and padding are left at defaults.

It happens here (currently line 475):

        let border_width = if self.borders { 1 } else { 0 } + if self.padding { 1 } else { 0 };
        let foot_width = self.width - (border_width * 2);

In this case, self.width is stil 0, border_width becomes "1" becoming:

let foot_width = 0 - (1 * 2) // panic - attempt to subtract with overflow
finish() doesn't panic for obvious reasons - but does print what amounts to an empty line.

I sort of hoped that in the case of no printed rows, I would be able to print an empty table or even a table with a "No data" row or something like that. I'm not sure how useful this is, though. I think it's probably worth fixing the panic, though.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions