Skip to content

Commit 478c24c

Browse files
committed
Implement comparison between &Atom and &str.
1 parent d835f0f commit 478c24c

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22

33
name = "string_cache"
4-
version = "0.2.14"
4+
version = "0.2.15"
55
authors = [ "The Servo Project Developers" ]
66
description = "A string interning library for Rust, developed as part of the Servo project."
77
license = "MIT / Apache-2.0"

src/atom/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,18 @@ impl Atom {
182182
}
183183
}
184184

185+
impl PartialEq<str> for Atom {
186+
fn eq(&self, other: &str) -> bool {
187+
&self[..] == other
188+
}
189+
}
190+
191+
impl PartialEq<Atom> for str {
192+
fn eq(&self, other: &Atom) -> bool {
193+
self == &other[..]
194+
}
195+
}
196+
185197
impl<'a> From<Cow<'a, str>> for Atom {
186198
#[inline]
187199
fn from(string_to_add: Cow<'a, str>) -> Atom {

0 commit comments

Comments
 (0)