Use if() instead of match here, to have less noise
This commit is contained in:
parent
0cca04c6ac
commit
8d89f7bf74
1 changed files with 9 additions and 12 deletions
|
@ -19,6 +19,7 @@ use std::io::stdin;
|
||||||
use std::io::BufRead;
|
use std::io::BufRead;
|
||||||
|
|
||||||
use task_hookrs::import::{import_task, import_tasks};
|
use task_hookrs::import::{import_task, import_tasks};
|
||||||
|
use task_hookrs::status::TaskStatus;
|
||||||
|
|
||||||
use libimagrt::runtime::Runtime;
|
use libimagrt::runtime::Runtime;
|
||||||
use libimagrt::setup::generate_runtime_setup;
|
use libimagrt::setup::generate_runtime_setup;
|
||||||
|
@ -62,7 +63,7 @@ fn tw_hook(rt: &Runtime) {
|
||||||
let stdin = stdin.lock();
|
let stdin = stdin.lock();
|
||||||
|
|
||||||
match import_tasks(stdin) {
|
match import_tasks(stdin) {
|
||||||
Ok(ttasks) => for (counter, ttask) in ttasks.enumerate() {
|
Ok(ttasks) => for (counter, ttask) in ttasks.iter().enumerate() {
|
||||||
if counter % 2 == 1 {
|
if counter % 2 == 1 {
|
||||||
// Only every second task is needed, the first one is the
|
// Only every second task is needed, the first one is the
|
||||||
// task before the change, and the second one after
|
// task before the change, and the second one after
|
||||||
|
@ -76,19 +77,15 @@ fn tw_hook(rt: &Runtime) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
match ttask.status() {
|
if *ttask.status() == TaskStatus::Deleted {
|
||||||
&task_hookrs::status::TaskStatus::Deleted => {
|
match Task::delete_by_uuid(rt.store(), *ttask.uuid()) {
|
||||||
match Task::delete_by_uuid(rt.store(), *ttask.uuid()) {
|
Ok(_) => println!("Deleted task {}", *ttask.uuid()),
|
||||||
Ok(_) => println!("Deleted task {}", *ttask.uuid()),
|
Err(e) => {
|
||||||
Err(e) => {
|
trace_error(&e);
|
||||||
trace_error(&e);
|
exit(1);
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
}
|
||||||
}
|
|
||||||
} // end match ttask.status()
|
|
||||||
} // end if c % 2
|
} // end if c % 2
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
|
Loading…
Reference in a new issue