diff options
author | Pro <twisted.fall@gmail.com> | 2024-02-09 21:53:42 +0100 |
---|---|---|
committer | Pro <twisted.fall@gmail.com> | 2024-02-09 21:53:42 +0100 |
commit | 1ba7fa469d04530444eb0bc6d7c9ee2fd41457f6 (patch) | |
tree | cc732a509acad26a5f484246eefaddddde776154 /examples | |
parent | 3fe862d63b4be68f62f8de737c5322ce22ea8dd9 (diff) |
Bump edition to 2021 and introduce rustfmt
Diffstat (limited to 'examples')
-rw-r--r-- | examples/main.rs | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/examples/main.rs b/examples/main.rs index 75bc9ff..53a328d 100644 --- a/examples/main.rs +++ b/examples/main.rs @@ -4,34 +4,38 @@ use kairos::timetype::TimeType as TT; fn pretty_print(tt: TT) { match tt { - TT::Seconds(e) => println!("{} Seconds", e), - TT::Minutes(e) => println!("{} Minutes", e), - TT::Hours(e) => println!("{} Hours", e), - TT::Days(e) => println!("{} Days", e), - TT::Months(e) => println!("{} Months", e), - TT::Years(e) => println!("{} Years", e), + TT::Seconds(e) => println!("{} Seconds", e), + TT::Minutes(e) => println!("{} Minutes", e), + TT::Hours(e) => println!("{} Hours", e), + TT::Days(e) => println!("{} Days", e), + TT::Months(e) => println!("{} Months", e), + TT::Years(e) => println!("{} Years", e), TT::Moment(ndt) => println!("{} ", ndt), - other => println!("Cannot pretty-print: '{:?}'", other), + other => println!("Cannot pretty-print: '{:?}'", other), } } fn main() { // not sure whether this is actually fast or something, but we don't care here, do we? - let s = ::std::env::args().skip(1).fold(String::new(), |acc, obj| format!("{} {}", acc, obj)); + let s = std::env::args() + .skip(1) + .fold(String::new(), |acc, obj| format!("{} {}", acc, obj)); let s = s.trim(); // because kairos is not yet whitespace tolerant match kairos::parser::parse(s) { Err(e) => println!("Error -> {:?}", e), Ok(kairos::parser::Parsed::TimeType(tt)) => match tt.calculate() { - Ok(r) => pretty_print(r), + Ok(r) => pretty_print(r), Err(e) => println!("Error calculating: {:?}", e), }, - Ok(kairos::parser::Parsed::Iterator(Ok(ui))) => for elem in ui { - match elem { - Ok(r) => pretty_print(r), - Err(e) => { - println!("Error calculating: {:?}", e); - ::std::process::exit(1) + Ok(kairos::parser::Parsed::Iterator(Ok(ui))) => { + for elem in ui { + match elem { + Ok(r) => pretty_print(r), + Err(e) => { + println!("Error calculating: {:?}", e); + std::process::exit(1) + }, } } }, |