Struct grid_printer::GridPrinter[][src]

pub struct GridPrinter { /* fields omitted */ }
Expand description

An API to easily print a two dimensional array to stdout.

Example

use grid_printer::GridPrinter;

let cars = vec![
    vec!["Make", "Model", "Color", "Year", "Price", ],
    vec!["Ford", "Pinto", "Green", "1978", "$750.00", ],
    vec!["Toyota", "Tacoma", "Red", "2006", "$15,475.23", ],
    vec!["Lamborghini", "Diablo", "Yellow", "2001", "$238,459.99", ],
];
 
let rows = cars.len();
let cols = cars[0].len();
let printer = GridPrinter::builder(rows, cols)
    .col_spacing(4)
    .build();
printer.print(&cars);

Output:

Make           Model     Color     Year    Price
Ford           Pinto     Green     1978    $750.00
Toyota         Tacoma    Red       2006    $15,475.23
Lamborghini    Diablo    Yellow    2001    $238,459.99

Implementations

impl GridPrinter[src]

pub fn new(rows: usize, cols: usize) -> Self[src]

pub fn builder(rows: usize, cols: usize) -> GridPrinterBuilder[src]

pub fn print_cell(
    &self,
    cell: &str,
    col_idx: usize,
    style_opt: Option<&StyleOpt>
)
[src]

pub fn print<F: Display>(&self, source: &[Vec<F>])[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.