From 7e4166acbff3bf60c3be2bcd713658b94a4659f0 Mon Sep 17 00:00:00 2001 From: Kai Sickeler Date: Sat, 16 Jul 2016 20:44:50 +0200 Subject: [PATCH] changed Unit-String to CounterUnit-Type --- imag-counter/src/create.rs | 3 ++- libimagcounter/src/counter.rs | 10 ++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/imag-counter/src/create.rs b/imag-counter/src/create.rs index 8bfcba67..96b58b54 100644 --- a/imag-counter/src/create.rs +++ b/imag-counter/src/create.rs @@ -3,6 +3,7 @@ use std::str::FromStr; use libimagrt::runtime::Runtime; use libimagerror::trace::trace_error_exit; use libimagcounter::counter::Counter; +use libimagcounter::counter::CounterUnit; pub fn create(rt: &Runtime) { rt.cli() @@ -19,7 +20,7 @@ pub fn create(rt: &Runtime) { .value_of("unit") .unwrap_or("unit"); - match Counter::new(rt.store(), String::from(name), init, String::from(unit)) { + match Counter::new(rt.store(), String::from(name), init, CounterUnit(String::from(unit))) { Err(e) => { warn!("Could not create Counter '{}' with initial value '{} {}'", name, init, unit); trace_error_exit(&e, 1); diff --git a/libimagcounter/src/counter.rs b/libimagcounter/src/counter.rs index 76101049..f0ccc217 100644 --- a/libimagcounter/src/counter.rs +++ b/libimagcounter/src/counter.rs @@ -137,12 +137,10 @@ impl<'a> Counter<'a> { pub fn unit(&self) -> Result { self.fle.get_header().read("counter.unit") .map_err(|e| CEK::StoreWriteError.into_error_with_cause(Box::new(e))) - .and_then(|u| - match u { - Some(Value::String(s)) => Ok(CounterUnit(s)), - _ => Err(CEK::HeaderTypeError.into_error()) - } - ) + .and_then(|u| match u { + Some(Value::String(s)) => Ok(CounterUnit(s)), + _ => Err(CEK::HeaderTypeError.into_error()) + }) } pub fn load(name: CounterName, store: &Store) -> Result {