pub fn counter_with<T, F>(&self, id: T, make_counter: F) -> Arc<Counter>
    where
        T: Into<MetricId>,
        F: FnOnce() -> Counter,
    {
        match Arc::make_mut(&mut self.metrics.lock()).entry(Arc::new(id.into())) {
            Entry::Occupied(e) => match e.get() {
                Metric::Counter(c) => c.clone(),
                _ => panic!("metric already registered as a non-counter: {:?}", e.key()),
            },
            Entry::Vacant(e) => {
                let counter = Arc::new(make_counter());
                e.insert(Metric::Counter(counter.clone()));
                counter
            }
        }
    }
/// Returns the counter with the specified ID, using make_counter to create it if absent.
///
/// # Panics
///
/// Panics if a metric is registered with the ID that is not a counter.
Returns the counter with the specified ID, using make_counter to create it if absent.
Returns the counter with the specified ID using make_counter to create it if absent .
pub fn counter_with<T, F>(&self, id: T, make_counter: F) -> Arc<Counter>
    where
        T: Into<MetricId>,
        F: FnOnce() -> Counter,
    {
        match Arc::make_mut(&mut self.metrics.lock()).entry(Arc::new(id.into())) {
            Entry::Occupied(e) => match e.get() {
                Metric::Counter(c) => c.clone(),
                _ => panic!("metric already registered as a non-counter: {:?}", e.key()),
            },
            Entry::Vacant(e) => {
                let counter = Arc::new(make_counter());
                e.insert(Metric::Counter(counter.clone()));
                counter
            }
        }
    }
pub fn counter_with < T , F > ( & self , id : T , make_counter : F ) -> Arc < Counter > where T : Into < MetricId > , F : FnOnce ( ) -> Counter , { match Arc :: make_mut ( & mut self . metrics . lock ( ) ) . entry ( Arc :: new ( id . into ( ) ) ) { Entry :: Occupied ( e ) => match e . get ( ) { Metric :: Counter ( c ) => c . clone ( ) , _ => panic ! ( " " e key ( ) ) , } , Entry :: Vacant ( e ) => { let counter = Arc :: new ( make_counter ( ) ) ; e . insert ( Metric :: Counter ( counter . clone ( ) ) ) ; counter } } }
Returns the counter with the specified ID, using make_counter to create it if absent.
Returns the counter with the specified ID using make_counter to create it if absent .
&self
id
T
make_counter
F
&self
id
T
make_counter
F
panics
Panics if a metric is registered with the ID that is not a counter.
Panics if a metric is registered with the ID that is not a counter .