Struct papergrid::Grid [−][src]
pub struct Grid { /* fields omitted */ }
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}; let mut grid = Grid::new(2, 2); 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}; let mut grid = Grid::new(2, 2); 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_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
Get_border_mut returns a border for a given row. The border can be modified.
Example
use papergrid::{Grid, Entity, Settings}; let mut grid = Grid::new(2, 2); grid.set(Entity::Global, Settings::new().text("asd")); grid.get_border_mut(0).empty() .top('─', '┬', Some('┌'), Some('┐')) .bottom('─', '┼', Some('├'), Some('┤')) .inner(Some('│'), Some('│'), Some('│')); grid.get_border_mut(1).empty() .top('─', '┬', Some('┌'), Some('┐')) .bottom('─', '┴', Some('└'), Some('┘')) .inner(Some('│'), Some('│'), Some('│')); let str = grid.to_string(); assert_eq!( str, "┌───┬───┐\n\ │asd│asd│\n\ ├───┼───┤\n\ │asd│asd│\n\ └───┴───┘\n" )
Remove_row removes a row
from a grid.
The row index must be started from 0
Remove_row removes a column
from a grid.
The column index must be started from 0
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Grid
impl UnwindSafe for Grid