Skip to content

Commit 37b459f

Browse files
committed
Add trivial impl of Borrow<str> for Atom
This enables Atom to be used in methods like HashMap::entry_ref.
1 parent 25413c9 commit 37b459f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/trivial_impls.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use crate::{Atom, StaticAtomSet};
1111
#[cfg(feature = "serde_support")]
1212
use serde::{Deserialize, Deserializer, Serialize, Serializer};
13-
use std::borrow::Cow;
13+
use std::borrow::{Borrow, Cow};
1414
use std::fmt;
1515

1616
impl<Static: StaticAtomSet> ::precomputed_hash::PrecomputedHash for Atom<Static> {
@@ -70,6 +70,12 @@ impl<Static: StaticAtomSet> AsRef<str> for Atom<Static> {
7070
}
7171
}
7272

73+
impl<Static: StaticAtomSet> Borrow<str> for Atom<Static> {
74+
fn borrow(&self) -> &str {
75+
self
76+
}
77+
}
78+
7379
#[cfg(feature = "serde_support")]
7480
impl<Static: StaticAtomSet> Serialize for Atom<Static> {
7581
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>

0 commit comments

Comments
 (0)