diff options
author | Ms2ger <ms2ger@gmail.com> | 2015-04-25 15:24:27 +0200 |
---|---|---|
committer | Ms2ger <ms2ger@gmail.com> | 2015-04-25 15:24:27 +0200 |
commit | 41cc0a939e552f0898ab4cdeb7c4ebddb6378090 (patch) | |
tree | aea6fdde87c438b62a10c9a4e57a40f914925a44 /components/script/dom/attr.rs | |
parent | 4108af0c113fcbd64abf2a1cf71026c2f7a653d3 (diff) | |
download | servo-41cc0a939e552f0898ab4cdeb7c4ebddb6378090.tar.gz servo-41cc0a939e552f0898ab4cdeb7c4ebddb6378090.zip |
Replace the Str implementation for AttrValue by a Deref implementation.
Diffstat (limited to 'components/script/dom/attr.rs')
-rw-r--r-- | components/script/dom/attr.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/components/script/dom/attr.rs b/components/script/dom/attr.rs index 1820a854cd8..536600e5f34 100644 --- a/components/script/dom/attr.rs +++ b/components/script/dom/attr.rs @@ -23,6 +23,7 @@ use string_cache::{Atom, Namespace}; use std::borrow::ToOwned; use std::cell::Ref; use std::mem; +use std::ops::Deref; pub enum AttrSettingType { FirstSetAttr, @@ -79,8 +80,10 @@ impl AttrValue { } } -impl Str for AttrValue { - fn as_slice<'a>(&'a self) -> &'a str { +impl Deref for AttrValue { + type Target = str; + + fn deref<'a>(&'a self) -> &'a str { match *self { AttrValue::String(ref value) | AttrValue::TokenList(ref value, _) | @@ -151,7 +154,7 @@ impl<'a> AttrMethods for JSRef<'a, Attr> { // https://dom.spec.whatwg.org/#dom-attr-value fn Value(self) -> DOMString { - self.value().as_slice().to_owned() + (**self.value()).to_owned() } // https://dom.spec.whatwg.org/#dom-attr-value @@ -299,7 +302,7 @@ impl AttrHelpersForLayout for Attr { unsafe fn value_ref_forever(&self) -> &'static str { // This transmute is used to cheat the lifetime restriction. let value = mem::transmute::<&AttrValue, &AttrValue>(self.value.borrow_for_layout()); - value.as_slice() + &**value } #[inline] |