From a757b37d86eba14ef5a8cc3757dee994e3ce5b47 Mon Sep 17 00:00:00 2001 From: pierresy Date: Mon, 1 Jun 2015 00:00:35 +0200 Subject: * Manage multi line rows * Capability to orint tables into tables (Yo dawg ;)) --- examples/basic.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'examples/basic.rs') diff --git a/examples/basic.rs b/examples/basic.rs index 459e89b..3996f4c 100644 --- a/examples/basic.rs +++ b/examples/basic.rs @@ -1,5 +1,7 @@ #[macro_use] extern crate tabprint; use tabprint::Table; +use tabprint::row::Row; +use tabprint::cell::Cell; /* Following main function will print : @@ -20,12 +22,16 @@ use tabprint::Table; +---------+------+---------+ */ 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(); + let mut table = Table::new(row!["ABC", "DEFG", "HIJKLMN"]); + table.add_row(row!["foobar", "bar", "foo"]).unwrap(); + table.add_row(Row::new(vec![ + Cell::new(&"foobar2".to_string()), + Cell::new(&"bar2".to_string()), + Cell::new(&"foo2".to_string())]) + ).unwrap(); table.printstd(); println!("Modified : "); - table.set_element("new_foo".to_string(), 2, 1).unwrap(); + table.set_element(&"new_foo".to_string(), 2, 1).unwrap(); table.printstd(); // The same table can be built the following way : -- cgit v1.2.3