Skip to content

Commit

Permalink
Convert unwrapping of ByteString to self.0
Browse files Browse the repository at this point in the history
Convert traditional unwrapping of the tuple struct ByteString to
self.0
  • Loading branch information
dlrobertson committed Feb 18, 2016
1 parent d23774d commit 72f74c2
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions components/script/dom/bindings/str.rs
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 72f74c2

Please sign in to comment.