diff options
author | pierresy <pierre-henri.symoneaux@alcatel-lucent.com> | 2015-05-28 14:13:15 +0200 |
---|---|---|
committer | pierresy <pierre-henri.symoneaux@alcatel-lucent.com> | 2015-05-28 14:19:10 +0200 |
commit | d7511dc07c33c4d4a0a312644ba65b65681a54ad (patch) | |
tree | 6d7dbcd6f1e1a56535087af449c846dbf1a3fd1c | |
parent | 365817f413fd3c921634a0fc716974e142525fa7 (diff) |
Updated examples and cargo.toml
-rw-r--r-- | Cargo.toml | 5 | ||||
-rw-r--r-- | README.md | 14 | ||||
-rw-r--r-- | example/basic.rs | 11 | ||||
-rw-r--r-- | src/main.rs | 14 |
4 files changed, 33 insertions, 11 deletions
@@ -2,7 +2,12 @@ name = "tabprint"
version = "0.0.1"
+description = "A small rust library that print aligned and formatted tables"
+repository = "https://github.com/phsym/tabprint"
+readme = "README.md"
authors = [ "Pierre-Henri Symoneaux" ]
+keywords = ["tab", "table", "format", "pretty", "aligned"]
+license = "BSD-3-Clause"
[[bin]]
@@ -33,7 +33,7 @@ Then you can start using it the following way : ```rust
#[macro_use] extern crate tabprint;
-use tabprint::Table
+use tabprint::Table;
fn main() {
let mut table = Table::new(vec!["ABC".to_string(), "DEFG".to_string(), "HIJKLMN".to_string()]);
@@ -43,4 +43,16 @@ fn main() { }
```
+This code will produce the following output :
+
+```text
++---------+------+---------+
+| ABC | DEFG | HIJKLMN |
++---------+------+---------+
+| foobar | bar | foo |
++---------+------+---------+
+| foobar2 | bar2 | foo2 |
++---------+------+---------+
+```
+
Additional examples are provided in documentation and in [examples](./examples/) directory
diff --git a/example/basic.rs b/example/basic.rs index b9df205..6a54cd0 100644 --- a/example/basic.rs +++ b/example/basic.rs @@ -10,10 +10,21 @@ use tabprint::Table; +---------+------+---------+
| foobar2 | bar2 | foo2 |
+---------+------+---------+
+ Modified :
+ +---------+------+---------+
+ | ABC | DEFG | HIJKLMN |
+ +---------+------+---------+
+ | foobar | bar | foo |
+ +---------+------+---------+
+ | foobar2 | bar2 | new_foo |
+ +---------+------+---------+
*/
fn main() {
let mut table = Table::new(vec!["ABC".to_string(), "DEFG".to_string(), "HIJKLMN".to_string()]);
table.add_row(vec!["foobar".to_string(), "bar".to_string(), "foo".to_string()]).unwrap();
table.add_row(vec!["foobar2".to_string(), "bar2".to_string(), "foo2".to_string()]).unwrap();
table.print();
+ println!("Modified : ");
+ table.set_element("new_foo".to_string(), 2, 1).unwrap();
+ table.print();
}
diff --git a/src/main.rs b/src/main.rs index b9df205..47884b9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,19 +1,13 @@ extern crate tabprint;
use tabprint::Table;
-/*
- Following main function will print :
- +---------+------+---------+
- | ABC | DEFG | HIJKLMN |
- +---------+------+---------+
- | foobar | bar | foo |
- +---------+------+---------+
- | foobar2 | bar2 | foo2 |
- +---------+------+---------+
-*/
+#[allow(dead_code)]
fn main() {
let mut table = Table::new(vec!["ABC".to_string(), "DEFG".to_string(), "HIJKLMN".to_string()]);
table.add_row(vec!["foobar".to_string(), "bar".to_string(), "foo".to_string()]).unwrap();
table.add_row(vec!["foobar2".to_string(), "bar2".to_string(), "foo2".to_string()]).unwrap();
table.print();
+ println!("Modified : ");
+ table.set_element("new_foo".to_string(), 2, 1).unwrap();
+ table.print();
}
|