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