mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Implement Borrow<str> for DOMString
Useful to use DOMString as a HashMap key type.
This commit is contained in:
parent
dd33be4548
commit
20b131af17
1 changed files with 8 additions and 1 deletions
|
@ -5,7 +5,7 @@
|
||||||
//! The `ByteString` struct.
|
//! The `ByteString` struct.
|
||||||
|
|
||||||
use std::ascii::AsciiExt;
|
use std::ascii::AsciiExt;
|
||||||
use std::borrow::{ToOwned, Cow};
|
use std::borrow::{Borrow, Cow, ToOwned};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::hash::{Hash, Hasher};
|
use std::hash::{Hash, Hasher};
|
||||||
use std::ops;
|
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 {
|
impl Default for DOMString {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
DOMString(String::new())
|
DOMString(String::new())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue