Struct prettytable::TableSlice [−][src]
pub struct TableSlice<'a> { /* fields omitted */ }A borrowed immutable Table slice
A TableSlice is obtained by slicing a Table with the Slice::slice method.
Examples
use prettytable::{Table, Slice}; let table = table![[1, 2, 3], [4, 5, 6], [7, 8, 9]]; let slice = table.slice(1..); slice.printstd(); // Prints only rows 1 and 2 //Also supports other syntax : table.slice(..); table.slice(..2); table.slice(1..3);
Methods
impl<'a> TableSlice<'a>[src]
impl<'a> TableSlice<'a>pub fn to_csv<W: Write>(&self, w: W) -> Result<Writer<W>>[src]
pub fn to_csv<W: Write>(&self, w: W) -> Result<Writer<W>>Write the table to the specified writer.
pub fn to_csv_writer<W: Write>(&self, writer: Writer<W>) -> Result<Writer<W>>[src]
pub fn to_csv_writer<W: Write>(&self, writer: Writer<W>) -> Result<Writer<W>>Write the table to the specified writer.
This allows for format customisation.
impl<'a> TableSlice<'a>[src]
impl<'a> TableSlice<'a>pub fn get_column_num(&self) -> usize[src]
pub fn get_column_num(&self) -> usize: Will become private in future release. See issue #87
Compute and return the number of column
pub fn len(&self) -> usize[src]
pub fn len(&self) -> usizeGet the number of rows
pub fn is_empty(&self) -> bool[src]
pub fn is_empty(&self) -> boolCheck if the table slice is empty
pub fn get_row(&self, row: usize) -> Option<&Row>[src]
pub fn get_row(&self, row: usize) -> Option<&Row>Get an immutable reference to a row
ⓘImportant traits for ColumnIter<'a>pub fn column_iter(&self, column: usize) -> ColumnIter[src]
pub fn column_iter(&self, column: usize) -> ColumnIterReturns an iterator over the immutable cells of the column specified by column
ⓘImportant traits for Iter<'a, T>pub fn row_iter(&self) -> Iter<Row>[src]
pub fn row_iter(&self) -> Iter<Row>Returns an iterator over immutable rows
pub fn print<T: Write + ?Sized>(&self, out: &mut T) -> Result<usize, Error>[src]
pub fn print<T: Write + ?Sized>(&self, out: &mut T) -> Result<usize, Error>Print the table to out and returns the number of
line printed, or an error
pub fn print_term<T: Terminal + ?Sized>(
&self,
out: &mut T
) -> Result<usize, Error>[src]
pub fn print_term<T: Terminal + ?Sized>(
&self,
out: &mut T
) -> Result<usize, Error>Print the table to terminal out, applying styles when needed and returns the number of
line printed, or an error
pub fn print_tty(&self, force_colorize: bool) -> usize[src]
pub fn print_tty(&self, force_colorize: bool) -> usizePrint the table to standard output. Colors won't be displayed unless
stdout is a tty terminal, or force_colorize is set to true.
In ANSI terminals, colors are displayed using ANSI escape characters. When for example the
output is redirected to a file, or piped to another program, the output is considered
as not beeing tty, and ANSI escape characters won't be displayed unless force colorize
is set to true.
Returns
The number of lines printed
Panic
Panic if writing to standard output fails
pub fn printstd(&self) -> usize[src]
pub fn printstd(&self) -> usizePrint the table to standard output. Colors won't be displayed unless
stdout is a tty terminal. This means that if stdout is redirected to a file, or piped
to another program, no color will be displayed.
To force colors rendering, use print_tty() method.
Calling printstd() is equivalent to calling print_tty(false)
Returns
The number of lines printed
Panic
Panic if writing to standard output fails
Trait Implementations
impl<'a> Clone for TableSlice<'a>[src]
impl<'a> Clone for TableSlice<'a>fn clone(&self) -> TableSlice<'a>[src]
fn clone(&self) -> TableSlice<'a>Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)Performs copy-assignment from source. Read more
impl<'a> Debug for TableSlice<'a>[src]
impl<'a> Debug for TableSlice<'a>fn fmt(&self, f: &mut Formatter) -> Result[src]
fn fmt(&self, f: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl<'a> Hash for TableSlice<'a>[src]
impl<'a> Hash for TableSlice<'a>fn hash<__H: Hasher>(&self, state: &mut __H)[src]
fn hash<__H: Hasher>(&self, state: &mut __H)Feeds this value into the given [Hasher]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, Feeds a slice of this type into the given [Hasher]. Read more
impl<'a> PartialEq for TableSlice<'a>[src]
impl<'a> PartialEq for TableSlice<'a>fn eq(&self, other: &TableSlice<'a>) -> bool[src]
fn eq(&self, other: &TableSlice<'a>) -> boolThis method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &TableSlice<'a>) -> bool[src]
fn ne(&self, other: &TableSlice<'a>) -> boolThis method tests for !=.
impl<'a> Eq for TableSlice<'a>[src]
impl<'a> Eq for TableSlice<'a>impl<'a> IntoIterator for &'a TableSlice<'a>[src]
impl<'a> IntoIterator for &'a TableSlice<'a>type Item = &'a Row
The type of the elements being iterated over.
type IntoIter = Iter<'a, Row>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter[src]
fn into_iter(self) -> Self::IntoIterCreates an iterator from a value. Read more
impl<'a> Index<usize> for TableSlice<'a>[src]
impl<'a> Index<usize> for TableSlice<'a>type Output = Row
The returned type after indexing.
fn index(&self, idx: usize) -> &Self::Output[src]
fn index(&self, idx: usize) -> &Self::OutputPerforms the indexing (container[index]) operation.
impl<'a> Display for TableSlice<'a>[src]
impl<'a> Display for TableSlice<'a>fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error>[src]
fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error>Formats the value using the given formatter. Read more
impl<'a> AsRef<TableSlice<'a>> for TableSlice<'a>[src]
impl<'a> AsRef<TableSlice<'a>> for TableSlice<'a>fn as_ref(&self) -> &TableSlice<'a>[src]
fn as_ref(&self) -> &TableSlice<'a>Performs the conversion.
impl<'a> AsRef<TableSlice<'a>> for Table[src]
impl<'a> AsRef<TableSlice<'a>> for Tablefn as_ref(&self) -> &TableSlice<'a>[src]
fn as_ref(&self) -> &TableSlice<'a>Performs the conversion.
Auto Trait Implementations
impl<'a> Send for TableSlice<'a>
impl<'a> Send for TableSlice<'a>impl<'a> Sync for TableSlice<'a>
impl<'a> Sync for TableSlice<'a>