diff options
author | Pierre-Henri Symoneaux <pierre-henri.symoneaux@nokia.com> | 2017-05-29 22:10:07 +0200 |
---|---|---|
committer | Pierre-Henri Symoneaux <pierre-henri.symoneaux@nokia.com> | 2017-05-29 22:10:07 +0200 |
commit | 0b633eb06f99a24f54070fe460068b2fa5ce1e13 (patch) | |
tree | dbc9095bb2ec623bee04382c74f356c327810a0b /src/main.rs | |
parent | c771c45b69de6b1c432e070cf6ac4d58c885488c (diff) |
Applied rustfmt on code
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 91 |
1 files changed, 46 insertions, 45 deletions
diff --git a/src/main.rs b/src/main.rs index 27940b8..9ee9b4d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,51 +1,52 @@ -//#![feature(trace_macros)]
-#[macro_use] extern crate prettytable;
-extern crate term;
-use prettytable::Table;
-use prettytable::row::Row;
-use prettytable::cell::Cell;
-use prettytable::format::*;
-
-use term::{Attr, color};
-
-//trace_macros!(true);
-
-#[allow(dead_code)]
-fn main() {
- let _ = table!();
- let mut table = Table::new();
- table.add_row(row![FrByb->"ABC", "DEFG", "HIJKLMN"]);
- table.add_row(row!["foobar", "bar", "foo"]);
- table.add_row(row![]);
- // Add style to a full row
- table.add_row(row![FY => "styled", "bar", "foo"]);
+//#![feature(trace_macros)] +#[macro_use] +extern crate prettytable; +extern crate term; +use prettytable::Table; +use prettytable::row::Row; +use prettytable::cell::Cell; +use prettytable::format::*; + +use term::{Attr, color}; + +//trace_macros!(true); + +#[allow(dead_code)] +fn main() { + let _ = table!(); + let mut table = Table::new(); + table.add_row(row![FrByb->"ABC", "DEFG", "HIJKLMN"]); + table.add_row(row!["foobar", "bar", "foo"]); + table.add_row(row![]); + // Add style to a full row + table.add_row(row![FY => "styled", "bar", "foo"]); table.add_row(Row::new(vec![
Cell::new("foobar2"),
// Create a cell with a red foreground color
Cell::new("bar2").with_style(Attr::ForegroundColor(color::RED)),
// Create a cell with red foreground color, yellow background color, with bold characters
Cell::new("foo2").style_spec("FrByb")])
- );
- for cell in table.column_iter_mut(2) {
- cell.align(Alignment::RIGHT);
- }
- for cell in table.column_iter_mut(1) {
- cell.align(Alignment::CENTER);
- }
- table.printstd();
- println!("Modified : ");
- table.set_element("new_foo", 2, 1).unwrap();
- table.printstd();
-
- // Print a table with some styles on it :
- // FrBybl means : Foregound red, Background yellow, bold, left align
- // d means : Default, do nothing
- ptable!([FrBybl->"A", "B", FrBybr->"C"], [d->123, 234, 345, 456]);
-
- // You can also apply style to full rows :
- let mut table = table!([Frb => "A", "B", "C"], [1, 2, 3, 4], ["A\nBCCZZZ\nDDD", 2, table]);
- table.set_titles(row!["Title 1", "Title 2"]);
- table.set_format(*consts::FORMAT_DEFAULT);
- table.printstd();
-// println!("{:#?}", table);
-}
+ ); + for cell in table.column_iter_mut(2) { + cell.align(Alignment::RIGHT); + } + for cell in table.column_iter_mut(1) { + cell.align(Alignment::CENTER); + } + table.printstd(); + println!("Modified : "); + table.set_element("new_foo", 2, 1).unwrap(); + table.printstd(); + + // Print a table with some styles on it : + // FrBybl means : Foregound red, Background yellow, bold, left align + // d means : Default, do nothing + ptable!([FrBybl->"A", "B", FrBybr->"C"], [d->123, 234, 345, 456]); + + // You can also apply style to full rows : + let mut table = table!([Frb => "A", "B", "C"], [1, 2, 3, 4], ["A\nBCCZZZ\nDDD", 2, table]); + table.set_titles(row!["Title 1", "Title 2"]); + table.set_format(*consts::FORMAT_DEFAULT); + table.printstd(); + // println!("{:#?}", table); +} |