diff options
Diffstat (limited to 'components/script/dom/bindings/str.rs')
-rw-r--r-- | components/script/dom/bindings/str.rs | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/components/script/dom/bindings/str.rs b/components/script/dom/bindings/str.rs index c252a8a3e21..f9ac9947af8 100644 --- a/components/script/dom/bindings/str.rs +++ b/components/script/dom/bindings/str.rs @@ -2,16 +2,15 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#![deny(missing_docs)] - //! The `ByteString` struct. -use std::hash::{Hash, sip}; +use std::borrow::ToOwned; +use std::hash::{Hash, SipHasher}; use std::str; use std::str::FromStr; /// Encapsulates the IDL `ByteString` type. -#[deriving(Clone,Eq,PartialEq)] +#[derive(Clone,Eq,PartialEq)] #[jstraceable] pub struct ByteString(Vec<u8>); @@ -25,7 +24,7 @@ impl ByteString { /// otherwise. pub fn as_str<'a>(&'a self) -> Option<&'a str> { let ByteString(ref vec) = *self; - str::from_utf8(vec.as_slice()) + str::from_utf8(vec.as_slice()).ok() } /// Returns the underlying vector as a slice. @@ -83,7 +82,7 @@ impl ByteString { /// [RFC 2616](http://tools.ietf.org/html/rfc2616#page-32). pub fn is_field_value(&self) -> bool { // Classifications of characters necessary for the [CRLF] (SP|HT) rule - #[deriving(PartialEq)] + #[derive(PartialEq)] enum PreviousCharacter { Other, CR, @@ -145,8 +144,8 @@ impl ByteString { } } -impl Hash for ByteString { - fn hash(&self, state: &mut sip::SipState) { +impl Hash<SipHasher> for ByteString { + fn hash(&self, state: &mut SipHasher) { let ByteString(ref vec) = *self; vec.hash(state); } @@ -154,6 +153,6 @@ impl Hash for ByteString { impl FromStr for ByteString { fn from_str(s: &str) -> Option<ByteString> { - Some(ByteString::new(s.into_string().into_bytes())) + Some(ByteString::new(s.to_owned().into_bytes())) } } |