pub struct Grid { /* private fields */ }
Expand description

Grid provides a set of methods for building a text-based table

Implementations

The new method creates a grid instance with default styles.

The size of the grid can not be changed after the instance is created.

Example
    use papergrid::{Grid, Entity, Settings, DEFAULT_CELL_STYLE};
    let mut grid = Grid::new(2, 2);
    grid.set_cell_borders(DEFAULT_CELL_STYLE.clone());
    let str = grid.to_string();
    assert_eq!(
         str,
         "+++\n\
          |||\n\
          +++\n\
          |||\n\
          +++\n"
    )

Set method is responsible for modification of cell/row/column.

The method panics if incorrect cell/row/column index is given.

Example
    use papergrid::{Grid, Entity, Settings, DEFAULT_CELL_STYLE};
    let mut grid = Grid::new(2, 2);
    grid.set_cell_borders(DEFAULT_CELL_STYLE.clone());
    grid.set(&Entity::Row(0), Settings::new().text("row 1"));
    grid.set(&Entity::Row(1), Settings::new().text("row 2"));
    let str = grid.to_string();
    assert_eq!(
         str,
         "+-----+-----+\n\
          |row 1|row 1|\n\
          +-----+-----+\n\
          |row 2|row 2|\n\
          +-----+-----+\n"
    )

get_cell_settings returns a settings of a cell

get_cell_content returns content without any style changes

Count_rows returns an amount of rows on the grid

Count_rows returns an amount of columns on the grid

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.