diff --git a/Cargo.toml b/Cargo.toml index 57c8cf8..0ddc506 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "string_cache" -version = "0.2.21" +version = "0.2.22" authors = [ "The Servo Project Developers" ] description = "A string interning library for Rust, developed as part of the Servo project." license = "MIT / Apache-2.0" diff --git a/src/atom/mod.rs b/src/atom/mod.rs index 89beb4e..4878320 100644 --- a/src/atom/mod.rs +++ b/src/atom/mod.rs @@ -203,6 +203,12 @@ impl Atom { } } +impl Default for Atom { + fn default() -> Self { + atom!("") + } +} + impl PartialEq for Atom { fn eq(&self, other: &str) -> bool { &self[..] == other @@ -215,6 +221,12 @@ impl PartialEq for str { } } +impl PartialEq for Atom { + fn eq(&self, other: &String) -> bool { + &self[..] == &other[..] + } +} + impl<'a> From> for Atom { #[inline] fn from(string_to_add: Cow<'a, str>) -> Atom { diff --git a/src/namespace.rs b/src/namespace.rs index cae98dd..9ae836b 100644 --- a/src/namespace.rs +++ b/src/namespace.rs @@ -15,7 +15,7 @@ use std::ops; /// An atom that is meant to represent a namespace in the HTML / XML sense. /// Whether a given string represents a namespace is contextual, so this is /// a transparent wrapper that will not catch all mistakes. -#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone)] +#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Default)] #[cfg_attr(feature = "heap_size", derive(HeapSizeOf))] pub struct Namespace(pub Atom);