Implement Borrow<str> for DOMString

Useful to use DOMString as a HashMap key type.
This commit is contained in:
Anthony Ramine 2016-09-06 15:31:43 +02:00
parent dd33be4548
commit 20b131af17

View file

@ -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;
@ -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())