Skip to content

Commit

Permalink
Implement Borrow<str> for DOMString
Browse files Browse the repository at this point in the history
Useful to use DOMString as a HashMap key type.
  • Loading branch information
nox committed Sep 7, 2016
1 parent dd33be4 commit 20b131a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion components/script/dom/bindings/str.rs
Expand Up @@ -5,7 +5,7 @@
//! The `ByteString` struct.

use std::ascii::AsciiExt;
use std::borrow::{ToOwned, Cow};
use std::borrow::{Borrow, Cow, ToOwned};
use std::fmt;
use std::hash::{Hash, Hasher};
use std::ops;
Expand Down Expand Up @@ -180,6 +180,13 @@ impl DOMString {
}
}

impl Borrow<str> for DOMString {
#[inline]
fn borrow(&self) -> &str {
&self.0
}
}

impl Default for DOMString {
fn default() -> Self {
DOMString(String::new())
Expand Down

0 comments on commit 20b131a

Please sign in to comment.