Struct papergrid::Grid [−][src]
pub struct Grid { /* fields omitted */ }
Expand description
Grid provides a set of methods for building a text-based table
Implementations
impl Grid
[src]
impl Grid
[src]pub fn new(rows: usize, columns: usize) -> Self
[src]
pub fn new(rows: usize, columns: usize) -> Self
[src]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" )
pub fn set(&mut self, entity: Entity, settings: Settings)
[src]
pub fn set(&mut self, entity: Entity, settings: Settings)
[src]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" )
pub fn count_rows(&self) -> usize
[src]
pub fn count_rows(&self) -> usize
[src]Count_rows returns an amount of rows on the grid
pub fn count_columns(&self) -> usize
[src]
pub fn count_columns(&self) -> usize
[src]Count_rows returns an amount of columns on the grid
pub fn get_border_mut(&mut self, row: usize) -> &mut Border
[src]
pub fn get_border_mut(&mut self, row: usize) -> &mut Border
[src]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" )
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Grid
impl Send for Grid
impl Sync for Grid
impl Unpin for Grid
impl UnwindSafe for Grid
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more