summaryrefslogtreecommitdiffstats
path: root/README.md
diff options
context:
space:
mode:
authorpierresy <phsym@msn.com>2016-01-04 21:10:21 +0100
committerpierresy <phsym@msn.com>2016-01-04 21:10:21 +0100
commit51a45a48e53d7cc826ad31cae3cb68acfbb284df (patch)
tree8e41205fa0906f275c1ab25e7cc3f3675c67c13b /README.md
parentd9c2ce1791a2f653570bee193b4d7b2a9223a568 (diff)
Updated readme with some explanation about table slicing (#10)
Diffstat (limited to 'README.md')
-rw-r--r--README.md21
1 files changed, 21 insertions, 0 deletions
diff --git a/README.md b/README.md
index 3f4ce41..652b5eb 100644
--- a/README.md
+++ b/README.md
@@ -195,4 +195,25 @@ Capital letters are for **bright** colors. Eg :
* **B** : Bright Blue
* ... and so on ...
+## Slicing
+
+Tables can be sliced into immutable borrowed subtables.
+Slices are of type `prettytable::TableSlice<'a>`.
+
+For example
+```rust
+use prettytable::Slice;
+(...)
+let slice = table.slice(2..5);
+table.printstd();
+```
+Would print a table with only lines 2, 3 and 4 from `table`.
+
+Other `Range` syntax are supported. For example :
+```rust
+table.slice(..); // Returns a borrowed immutable table with all rows
+table.slice(2..); // Returns a table with rows starting at index 2
+table.slice(..3); // Returns a table with rows until the one at index 3
+```
+
Additional examples are provided in documentation and in [examples](./examples/) directory