diff options
author | Corey Farwell <coreyf@rwell.org> | 2015-03-29 13:33:02 -0400 |
---|---|---|
committer | Corey Farwell <coreyf@rwell.org> | 2015-03-29 14:42:19 -0400 |
commit | d838fcce30d56e02bd22c4bcfca04d39bf4fc38e (patch) | |
tree | 3a906417b1c164990bc308ff790913b9c7c08740 /components/script/dom/htmlelement.rs | |
parent | b8ea10bfe3386357b68e5564332cf8ac9d5377bb (diff) | |
download | servo-d838fcce30d56e02bd22c4bcfca04d39bf4fc38e.tar.gz servo-d838fcce30d56e02bd22c4bcfca04d39bf4fc38e.zip |
Remove some unnecessary uses of `as_slice`
For the majority of these cases, `as_slice` can be removed due to
`Deref`. In particular, `Deref` for:
* `String` -> `str`
* `Atom` -> `str`
The latter of those two requires, a bump of the locked `string-cache`
library
Diffstat (limited to 'components/script/dom/htmlelement.rs')
-rw-r--r-- | components/script/dom/htmlelement.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs index a134b26584a..a0d0adaf82b 100644 --- a/components/script/dom/htmlelement.rs +++ b/components/script/dom/htmlelement.rs @@ -146,7 +146,7 @@ pub trait HTMLElementCustomAttributeHelpers { fn to_snake_case(name: DOMString) -> DOMString { let mut attr_name = "data-".to_owned(); - for ch in name.as_slice().chars() { + for ch in name.chars() { if ch.is_uppercase() { attr_name.push('\x2d'); attr_name.push(ch.to_lowercase()); @@ -170,7 +170,7 @@ impl<'a> HTMLElementCustomAttributeHelpers for JSRef<'a, HTMLElement> { fn get_custom_attr(self, name: DOMString) -> Option<DOMString> { let element: JSRef<Element> = ElementCast::from_ref(self); - element.get_attribute(ns!(""), &Atom::from_slice(to_snake_case(name).as_slice())).map(|attr| { + element.get_attribute(ns!(""), &Atom::from_slice(&to_snake_case(name))).map(|attr| { let attr = attr.root(); // FIXME(https://github.com/rust-lang/rust/issues/23338) let attr = attr.r(); @@ -181,7 +181,7 @@ impl<'a> HTMLElementCustomAttributeHelpers for JSRef<'a, HTMLElement> { fn delete_custom_attr(self, name: DOMString) { let element: JSRef<Element> = ElementCast::from_ref(self); - element.remove_attribute(ns!(""), to_snake_case(name).as_slice()) + element.remove_attribute(ns!(""), &to_snake_case(name)) } } @@ -196,7 +196,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLElement> { s.after_set_attr(attr); } - let name = attr.local_name().as_slice(); + let name = attr.local_name(); if name.starts_with("on") { let window = window_from_node(*self).root(); let (cx, url, reflector) = (window.r().get_cx(), |