use CounterUnit::new instead of a pub member

This commit is contained in:
Kai Sickeler 2016-07-17 16:26:11 +02:00
parent 7e4166acbf
commit aeb27072a7
2 changed files with 8 additions and 2 deletions

View file

@ -20,7 +20,7 @@ pub fn create(rt: &Runtime) {
.value_of("unit")
.unwrap_or("unit");
match Counter::new(rt.store(), String::from(name), init, CounterUnit(String::from(unit))) {
match Counter::new(rt.store(), String::from(name), init, CounterUnit::new(unit)) {
Err(e) => {
warn!("Could not create Counter '{}' with initial value '{} {}'", name, init, unit);
trace_error_exit(&e, 1);

View file

@ -21,7 +21,7 @@ use error::CounterErrorKind as CEK;
pub type CounterName = String;
#[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
pub struct CounterUnit(pub String);
pub struct CounterUnit(String);
impl Display for CounterUnit {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@ -29,6 +29,12 @@ impl Display for CounterUnit {
}
}
impl CounterUnit {
pub fn new<S: Into<String>>(unit: S) -> CounterUnit {
CounterUnit(unit.into())
}
}
pub struct Counter<'a> {
fle: FileLockEntry<'a>,
}