packages

table::display

On this page

Text forms of a table: the aligned preview Display prints (rows and columns cut in the middle past a limit) and GitHub-flavoured Markdown.

Constants

MAX_ROWSSource

pub const MAX_ROWS: usize = 10

Rows Display shows before cutting (half from each end).

MAX_COLSSource

pub const MAX_COLS: usize = 8

Columns Display shows before cutting.

MAX_WIDTHSource

pub const MAX_WIDTH: usize = 24

Code points of a cell before it is cut with ....

Implementations

impl Table

  • pub fn preview(self, max_rows: usize, max_cols: usize) -> str§

    Source

    The preview with at most max_rows rows and max_cols columns (the middle cut, marked ...), the shape on the first line and each column's type under its name.

    nabi
    let t = table::table!{ "a": [1, 2, 3], "b": ["x", "y", "z"] };
    let s = t.preview(2, 8);
    assert(s.starts_with("shape: (3, 2)"));
    assert(s.contains("..."));
    
  • pub fn to_markdown(self) -> str§

    Source

    The whole table as a GitHub-flavoured Markdown table: numbers right-aligned, | in a cell escaped, null as an empty cell.

    nabi
    let t = table::table!{ "name": ["a|b"], "n": [1] };
    assert(t.to_markdown() == "| name | n |\n| :--- | ---: |\n| a\\|b | 1 |\n");
    
Trait implementations 2