Struct prettytable::TableSlice
source · pub struct TableSlice<'a> { /* private fields */ }
Expand description
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);
Implementations§
source§impl<'a> TableSlice<'a>
impl<'a> TableSlice<'a>
source§impl<'a> TableSlice<'a>
impl<'a> TableSlice<'a>
sourcepub fn get_column_num(&self) -> usize
👎Deprecated since 0.8.0: Will become private in future release. See issue #87
pub fn get_column_num(&self) -> usize
Compute and return the number of column
sourcepub fn column_iter(&self, column: usize) -> ColumnIter<'_> ⓘ
pub fn column_iter(&self, column: usize) -> ColumnIter<'_> ⓘ
Returns an iterator over the immutable cells of the column specified by column
sourcepub fn print<T: Write + ?Sized>(&self, out: &mut T) -> Result<usize, Error>
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
sourcepub fn print_term<T: Terminal + ?Sized>(
&self,
out: &mut T,
) -> Result<usize, Error>
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
sourcepub fn print_tty(&self, force_colorize: bool) -> usize
pub fn print_tty(&self, force_colorize: bool) -> usize
Print 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
sourcepub fn printstd(&self) -> usize
pub fn printstd(&self) -> usize
Print 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§
source§impl<'a> AsRef<TableSlice<'a>> for TableSlice<'a>
impl<'a> AsRef<TableSlice<'a>> for TableSlice<'a>
source§fn as_ref(&self) -> &TableSlice<'a>
fn as_ref(&self) -> &TableSlice<'a>
source§impl<'a> Clone for TableSlice<'a>
impl<'a> Clone for TableSlice<'a>
source§fn clone(&self) -> TableSlice<'a>
fn clone(&self) -> TableSlice<'a>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<'a> Debug for TableSlice<'a>
impl<'a> Debug for TableSlice<'a>
source§impl<'a> Display for TableSlice<'a>
impl<'a> Display for TableSlice<'a>
source§impl<'a> Hash for TableSlice<'a>
impl<'a> Hash for TableSlice<'a>
source§impl<'a> Index<usize> for TableSlice<'a>
impl<'a> Index<usize> for TableSlice<'a>
source§impl<'a> IntoIterator for &'a TableSlice<'a>
impl<'a> IntoIterator for &'a TableSlice<'a>
source§impl<'a> PartialEq for TableSlice<'a>
impl<'a> PartialEq for TableSlice<'a>
source§fn eq(&self, other: &TableSlice<'a>) -> bool
fn eq(&self, other: &TableSlice<'a>) -> bool
self
and other
values to be equal, and is used
by ==
.impl<'a> Copy for TableSlice<'a>
impl<'a> Eq for TableSlice<'a>
impl<'a> StructuralPartialEq for TableSlice<'a>
Auto Trait Implementations§
impl<'a> Freeze for TableSlice<'a>
impl<'a> RefUnwindSafe for TableSlice<'a>
impl<'a> Send for TableSlice<'a>
impl<'a> Sync for TableSlice<'a>
impl<'a> Unpin for TableSlice<'a>
impl<'a> UnwindSafe for TableSlice<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)