diff options
author | Daniel Robertson <danlrobertson89@gmail.com> | 2016-02-18 14:18:01 +0000 |
---|---|---|
committer | Daniel Robertson <danlrobertson89@gmail.com> | 2016-02-18 19:41:03 +0000 |
commit | 72f74c27efe96912e7143f8e9bdf3f18774d31c0 (patch) | |
tree | 19f1e10da13db860a6aab45a047bcb054c392546 /components/script/dom/bindings/str.rs | |
parent | d23774d3d7dd1d1504e6a4d2266355477195d6c1 (diff) | |
download | servo-72f74c27efe96912e7143f8e9bdf3f18774d31c0.tar.gz servo-72f74c27efe96912e7143f8e9bdf3f18774d31c0.zip |
Convert unwrapping of ByteString to self.0
Convert traditional unwrapping of the tuple struct ByteString to
self.0
Diffstat (limited to 'components/script/dom/bindings/str.rs')
-rw-r--r-- | components/script/dom/bindings/str.rs | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/components/script/dom/bindings/str.rs b/components/script/dom/bindings/str.rs index 72e4fc4cd81..850277f596e 100644 --- a/components/script/dom/bindings/str.rs +++ b/components/script/dom/bindings/str.rs @@ -25,8 +25,7 @@ impl ByteString { /// Returns `self` as a string, if it encodes valid UTF-8, and `None` /// otherwise. pub fn as_str(&self) -> Option<&str> { - let ByteString(ref vec) = *self; - str::from_utf8(&vec).ok() + str::from_utf8(&self.0).ok() } /// Returns ownership of the underlying Vec<u8> and copies an empty @@ -37,8 +36,7 @@ impl ByteString { /// Returns the length. pub fn len(&self) -> usize { - let ByteString(ref vector) = *self; - vector.len() + self.0.len() } /// Compare `self` to `other`, matching A–Z and a–z as equal. @@ -54,8 +52,7 @@ impl ByteString { /// Returns whether `self` is a `token`, as defined by /// [RFC 2616](http://tools.ietf.org/html/rfc2616#page-17). pub fn is_token(&self) -> bool { - let ByteString(ref vec) = *self; - is_token(vec) + is_token(&self.0) } /// Returns whether `self` is a `field-value`, as defined by @@ -69,9 +66,8 @@ impl ByteString { LF, SPHT, // SP or HT } - let ByteString(ref vec) = *self; let mut prev = PreviousCharacter::Other; // The previous character - vec.iter().all(|&x| { + self.0.iter().all(|&x| { // http://tools.ietf.org/html/rfc2616#section-2.2 match x { 13 => { // CR |