use CounterUnit::new instead of a pub member
This commit is contained in:
parent
7e4166acbf
commit
aeb27072a7
2 changed files with 8 additions and 2 deletions
|
@ -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);
|
||||
|
|
|
@ -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>,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue