Skip to content

Commit

Permalink
Add Borrow impl to KeyName (metrics-rs#381)
Browse files Browse the repository at this point in the history
  • Loading branch information
hlbarber committed Jun 22, 2023
1 parent b927819 commit 9262c9d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions metrics/src/key.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::{atomics::AtomicU64, cow::Cow, IntoLabels, KeyHasher, Label, SharedString};
use std::{
borrow::Borrow,
cmp, fmt,
hash::{Hash, Hasher},
slice::Iter,
Expand Down Expand Up @@ -41,6 +42,13 @@ impl From<std::borrow::Cow<'static, str>> for KeyName {
KeyName(SharedString::from(name))
}
}

impl Borrow<str> for KeyName {
fn borrow(&self) -> &str {
self.0.borrow()
}
}

/// A metric identifier.
///
/// A key represents both the name and labels of a metric.
Expand Down

0 comments on commit 9262c9d

Please sign in to comment.