Merge pull request #356 from matthiasbeyer/imag-counter/zero-warnings
Imag counter/zero warnings
This commit is contained in:
commit
86ae4383a0
3 changed files with 29 additions and 10 deletions
|
@ -10,7 +10,6 @@ use libimagcounter::counter::Counter;
|
||||||
use libimagcounter::error::CounterError;
|
use libimagcounter::error::CounterError;
|
||||||
use libimagrt::runtime::Runtime;
|
use libimagrt::runtime::Runtime;
|
||||||
use libimagutil::key_value_split::IntoKeyValue;
|
use libimagutil::key_value_split::IntoKeyValue;
|
||||||
use libimagutil::key_value_split::KeyValue;
|
|
||||||
use libimagutil::trace::trace_error;
|
use libimagutil::trace::trace_error;
|
||||||
|
|
||||||
type Result<T> = RResult<T, CounterError>;
|
type Result<T> = RResult<T, CounterError>;
|
||||||
|
@ -18,7 +17,7 @@ type Result<T> = RResult<T, CounterError>;
|
||||||
pub fn interactive(rt: &Runtime) {
|
pub fn interactive(rt: &Runtime) {
|
||||||
let scmd = rt.cli().subcommand_matches("interactive");
|
let scmd = rt.cli().subcommand_matches("interactive");
|
||||||
if scmd.is_none() {
|
if scmd.is_none() {
|
||||||
write!(stderr(), "No subcommand");
|
debug!("No subcommand");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
let scmd = scmd.unwrap();
|
let scmd = scmd.unwrap();
|
||||||
|
@ -37,7 +36,7 @@ pub fn interactive(rt: &Runtime) {
|
||||||
pairs.insert('q', Binding::Function(String::from("quit"), Box::new(quit)));
|
pairs.insert('q', Binding::Function(String::from("quit"), Box::new(quit)));
|
||||||
}
|
}
|
||||||
|
|
||||||
stderr().flush();
|
stderr().flush().ok();
|
||||||
loop {
|
loop {
|
||||||
println!("---");
|
println!("---");
|
||||||
for (k, v) in &pairs {
|
for (k, v) in &pairs {
|
||||||
|
@ -59,10 +58,14 @@ pub fn interactive(rt: &Runtime) {
|
||||||
Some(&mut Binding::Counter(ref mut ctr)) => {
|
Some(&mut Binding::Counter(ref mut ctr)) => {
|
||||||
if increment {
|
if increment {
|
||||||
debug!("Incrementing");
|
debug!("Incrementing");
|
||||||
ctr.inc();
|
if let Err(e) = ctr.inc() {
|
||||||
|
trace_error(&e);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
debug!("Decrementing");
|
debug!("Decrementing");
|
||||||
ctr.dec();
|
if let Err(e) = ctr.dec() {
|
||||||
|
trace_error(&e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
},
|
},
|
||||||
|
@ -128,7 +131,7 @@ impl<'a> Display for Binding<'a> {
|
||||||
fn compute_pair<'a>(rt: &'a Runtime, spec: &str) -> Result<(char, Binding<'a>)> {
|
fn compute_pair<'a>(rt: &'a Runtime, spec: &str) -> Result<(char, Binding<'a>)> {
|
||||||
let kv = String::from(spec).into_kv();
|
let kv = String::from(spec).into_kv();
|
||||||
if kv.is_none() {
|
if kv.is_none() {
|
||||||
write!(stderr(), "Key-Value parsing failed!");
|
debug!("Key-Value parsing failed!");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
let kv = kv.unwrap();
|
let kv = kv.unwrap();
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
use libimagrt::runtime::Runtime;
|
use libimagrt::runtime::Runtime;
|
||||||
use libimagutil::trace::trace_error;
|
use libimagutil::trace::trace_error;
|
||||||
use libimagcounter::counter::Counter;
|
use libimagcounter::counter::Counter;
|
||||||
use libimagcounter::result::Result;
|
|
||||||
|
|
||||||
pub fn list(rt: &Runtime) {
|
pub fn list(rt: &Runtime) {
|
||||||
rt.cli()
|
rt.cli()
|
||||||
.subcommand_matches("list")
|
.subcommand_matches("list")
|
||||||
.map(|scmd| {
|
.map(|_| {
|
||||||
debug!("Found 'list' subcommand...");
|
debug!("Found 'list' subcommand...");
|
||||||
|
|
||||||
Counter::all_counters(rt.store()).map(|iterator| {
|
Counter::all_counters(rt.store()).map(|iterator| {
|
||||||
|
@ -26,7 +25,8 @@ pub fn list(rt: &Runtime) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.map_err(|e| trace_error(&e));
|
.map_err(|e| trace_error(&e))
|
||||||
|
.ok();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.map_err(|e| trace_error(&e))
|
.map_err(|e| trace_error(&e))
|
||||||
|
|
|
@ -1,3 +1,18 @@
|
||||||
|
#![deny(
|
||||||
|
non_camel_case_types,
|
||||||
|
non_snake_case,
|
||||||
|
path_statements,
|
||||||
|
trivial_numeric_casts,
|
||||||
|
unstable_features,
|
||||||
|
unused_allocation,
|
||||||
|
unused_import_braces,
|
||||||
|
unused_imports,
|
||||||
|
unused_must_use,
|
||||||
|
unused_mut,
|
||||||
|
unused_qualifications,
|
||||||
|
while_true,
|
||||||
|
)]
|
||||||
|
|
||||||
#[macro_use] extern crate log;
|
#[macro_use] extern crate log;
|
||||||
#[macro_use] extern crate version;
|
#[macro_use] extern crate version;
|
||||||
extern crate clap;
|
extern crate clap;
|
||||||
|
@ -118,7 +133,8 @@ fn main() {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
.map_err(|e| trace_error(&e));
|
.map_err(|e| trace_error(&e))
|
||||||
|
.ok();
|
||||||
},
|
},
|
||||||
|name| {
|
|name| {
|
||||||
debug!("Call: {}", name);
|
debug!("Call: {}", name);
|
||||||
|
|
Loading…
Reference in a new issue