Skip to content

Commit 12008ae

Browse files
author
bors-servo
authored
Auto merge of #165 - servo:default--partialeq-string, r=nox
Implement Default and PartialEq<String>. This is part of the changes proposed at servo/servo#12391 (comment) <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/string-cache/165) <!-- Reviewable:end -->
2 parents bb130c3 + 91314e0 commit 12008ae

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22

33
name = "string_cache"
4-
version = "0.2.21"
4+
version = "0.2.22"
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

+12
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,12 @@ impl Atom {
203203
}
204204
}
205205

206+
impl Default for Atom {
207+
fn default() -> Self {
208+
atom!("")
209+
}
210+
}
211+
206212
impl PartialEq<str> for Atom {
207213
fn eq(&self, other: &str) -> bool {
208214
&self[..] == other
@@ -215,6 +221,12 @@ impl PartialEq<Atom> for str {
215221
}
216222
}
217223

224+
impl PartialEq<String> for Atom {
225+
fn eq(&self, other: &String) -> bool {
226+
&self[..] == &other[..]
227+
}
228+
}
229+
218230
impl<'a> From<Cow<'a, str>> for Atom {
219231
#[inline]
220232
fn from(string_to_add: Cow<'a, str>) -> Atom {

src/namespace.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use std::ops;
1515
/// An atom that is meant to represent a namespace in the HTML / XML sense.
1616
/// Whether a given string represents a namespace is contextual, so this is
1717
/// a transparent wrapper that will not catch all mistakes.
18-
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone)]
18+
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Default)]
1919
#[cfg_attr(feature = "heap_size", derive(HeapSizeOf))]
2020
pub struct Namespace(pub Atom);
2121

0 commit comments

Comments
 (0)