Skip to content

Commit

Permalink
Added an example in documentation about TableSlice (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
pierresy committed Jan 4, 2016
1 parent 51a45a4 commit 3f5611d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,24 @@ pub struct Table {
}

/// A borrowed immutable `Table` slice
/// A `TableSlice` is obtained by slicing a `Table` with the `Slice::slice` method.
///
/// # Examples
/// ```rust
/// # #[macro_use] extern crate prettytable;
/// use prettytable::{Table, Slice};
/// # fn main() {
/// 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);
/// # }
/// ```
///
#[derive(Clone, Debug)]
pub struct TableSlice<'a> {
format: &'a TableFormat,
Expand Down

0 comments on commit 3f5611d

Please sign in to comment.