Skip to content

Commit

Permalink
src/registry.rs: Remove Add trait impls
Browse files Browse the repository at this point in the history
They interact with builtin implementation in confusing ways:
rust-lang/rust#77143

Fixes #68
  • Loading branch information
erenon authored and Benedek Thaler committed Jul 4, 2022
1 parent 69e6674 commit 445c9fe
Showing 1 changed file with 4 additions and 23 deletions.
27 changes: 4 additions & 23 deletions src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
//! See [`Registry`] for details.

use std::borrow::Cow;
use std::ops::Add;

/// A metric registry.
///
Expand Down Expand Up @@ -149,7 +148,7 @@ impl<M> Registry<M> {
name: self
.prefix
.as_ref()
.map(|p| (p.clone() + "_" + name.as_str()).into())
.map(|p| (p.clone().0 + "_" + name.as_str()))
.unwrap_or(name),
help,
unit,
Expand Down Expand Up @@ -196,13 +195,9 @@ impl<M> Registry<M> {
/// but namespacing with a label instead of a metric name prefix.
pub fn sub_registry_with_prefix<P: AsRef<str>>(&mut self, prefix: P) -> &mut Self {
let sub_registry = Registry {
prefix: Some(
self.prefix
.clone()
.map(|p| p + "_")
.unwrap_or_else(|| String::new().into())
+ prefix.as_ref(),
),
prefix: Some(Prefix(
self.prefix.clone().map(|p| p.0 + "_").unwrap_or_default() + prefix.as_ref(),
)),
labels: self.labels.clone(),
..Default::default()
};
Expand Down Expand Up @@ -292,20 +287,6 @@ impl From<Prefix> for String {
}
}

impl Add<&str> for Prefix {
type Output = Self;
fn add(self, rhs: &str) -> Self::Output {
Prefix(self.0 + rhs)
}
}

impl Add<&Prefix> for String {
type Output = Self;
fn add(self, rhs: &Prefix) -> Self::Output {
self + rhs.0.as_str()
}
}

pub struct Descriptor {
name: String,
help: String,
Expand Down

0 comments on commit 445c9fe

Please sign in to comment.