Skip to content

Commit 890d6e1

Browse files
committed
src/registry.rs: Remove Add trait impls
They interact with builtin implementation in confusing ways: rust-lang/rust#77143 Fixes #68 Signed-off-by: Benedek Thaler <[email protected]>
1 parent 69e6674 commit 890d6e1

File tree

1 file changed

+4
-23
lines changed

1 file changed

+4
-23
lines changed

src/registry.rs

+4-23
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
//! See [`Registry`] for details.
44
55
use std::borrow::Cow;
6-
use std::ops::Add;
76

87
/// A metric registry.
98
///
@@ -149,7 +148,7 @@ impl<M> Registry<M> {
149148
name: self
150149
.prefix
151150
.as_ref()
152-
.map(|p| (p.clone() + "_" + name.as_str()).into())
151+
.map(|p| (p.clone().0 + "_" + name.as_str()))
153152
.unwrap_or(name),
154153
help,
155154
unit,
@@ -196,13 +195,9 @@ impl<M> Registry<M> {
196195
/// but namespacing with a label instead of a metric name prefix.
197196
pub fn sub_registry_with_prefix<P: AsRef<str>>(&mut self, prefix: P) -> &mut Self {
198197
let sub_registry = Registry {
199-
prefix: Some(
200-
self.prefix
201-
.clone()
202-
.map(|p| p + "_")
203-
.unwrap_or_else(|| String::new().into())
204-
+ prefix.as_ref(),
205-
),
198+
prefix: Some(Prefix(
199+
self.prefix.clone().map(|p| p.0 + "_").unwrap_or_default() + prefix.as_ref(),
200+
)),
206201
labels: self.labels.clone(),
207202
..Default::default()
208203
};
@@ -292,20 +287,6 @@ impl From<Prefix> for String {
292287
}
293288
}
294289

295-
impl Add<&str> for Prefix {
296-
type Output = Self;
297-
fn add(self, rhs: &str) -> Self::Output {
298-
Prefix(self.0 + rhs)
299-
}
300-
}
301-
302-
impl Add<&Prefix> for String {
303-
type Output = Self;
304-
fn add(self, rhs: &Prefix) -> Self::Output {
305-
self + rhs.0.as_str()
306-
}
307-
}
308-
309290
pub struct Descriptor {
310291
name: String,
311292
help: String,

0 commit comments

Comments
 (0)