Skip to content

Commit

Permalink
Add Borrow impl to KeyName (#381)
Browse files Browse the repository at this point in the history
  • Loading branch information
hlbarber authored Jun 22, 2023
1 parent c282e44 commit c04028c
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 c04028c

Please sign in to comment.