fn add_metric(&mut self, metric: Metric) -> Option<Metric> {
        let metrics = self.metrics.get_or_insert(Vec::new());
        if let Some(i) = metrics.iter().position(|old_metric| old_metric.key == metric.key) {
            metrics.push(metric);
            Some(metrics.swap_remove(i))
        } else {
            metrics.push(metric);
            None
        }
    }
/// Adds the given metric to the given Object. If a metric with this key already exists, it is
/// replaced and the old value is returned.
Adds the given metric to the given Object. If a metric with this key already exists, it is
replaced and the old value is returned.
Adds the given metric to the given Object . If a metric with this key already exists it is replaced and the old value is returned .
fn add_metric(&mut self, metric: Metric) -> Option<Metric> {
        let metrics = self.metrics.get_or_insert(Vec::new());
        if let Some(i) = metrics.iter().position(|old_metric| old_metric.key == metric.key) {
            metrics.push(metric);
            Some(metrics.swap_remove(i))
        } else {
            metrics.push(metric);
            None
        }
    }
fn add_metric ( & mut self , metric : Metric ) -> Option < Metric > { let metrics = self . metrics . get_or_insert ( Vec :: new ( ) ) ; if let Some ( i ) = metrics . iter ( ) . position ( | old_metric | old_metric . key == metric . key ) { metrics . push ( metric ) ; Some ( metrics . swap_remove ( i ) ) } else { metrics . push ( metric ) ; None } }
Adds the given metric to the given Object.
Adds the given metric to the given Object .
&mut self
metric
Metric
&mut self
metric
Metric