mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Convert unwrapping of ByteString to self.0
Convert traditional unwrapping of the tuple struct ByteString to self.0
This commit is contained in:
parent
d23774d3d7
commit
72f74c27ef
1 changed files with 4 additions and 8 deletions
|
@ -25,8 +25,7 @@ impl ByteString {
|
||||||
/// Returns `self` as a string, if it encodes valid UTF-8, and `None`
|
/// Returns `self` as a string, if it encodes valid UTF-8, and `None`
|
||||||
/// otherwise.
|
/// otherwise.
|
||||||
pub fn as_str(&self) -> Option<&str> {
|
pub fn as_str(&self) -> Option<&str> {
|
||||||
let ByteString(ref vec) = *self;
|
str::from_utf8(&self.0).ok()
|
||||||
str::from_utf8(&vec).ok()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns ownership of the underlying Vec<u8> and copies an empty
|
/// Returns ownership of the underlying Vec<u8> and copies an empty
|
||||||
|
@ -37,8 +36,7 @@ impl ByteString {
|
||||||
|
|
||||||
/// Returns the length.
|
/// Returns the length.
|
||||||
pub fn len(&self) -> usize {
|
pub fn len(&self) -> usize {
|
||||||
let ByteString(ref vector) = *self;
|
self.0.len()
|
||||||
vector.len()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Compare `self` to `other`, matching A–Z and a–z as equal.
|
/// 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
|
/// Returns whether `self` is a `token`, as defined by
|
||||||
/// [RFC 2616](http://tools.ietf.org/html/rfc2616#page-17).
|
/// [RFC 2616](http://tools.ietf.org/html/rfc2616#page-17).
|
||||||
pub fn is_token(&self) -> bool {
|
pub fn is_token(&self) -> bool {
|
||||||
let ByteString(ref vec) = *self;
|
is_token(&self.0)
|
||||||
is_token(vec)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns whether `self` is a `field-value`, as defined by
|
/// Returns whether `self` is a `field-value`, as defined by
|
||||||
|
@ -69,9 +66,8 @@ impl ByteString {
|
||||||
LF,
|
LF,
|
||||||
SPHT, // SP or HT
|
SPHT, // SP or HT
|
||||||
}
|
}
|
||||||
let ByteString(ref vec) = *self;
|
|
||||||
let mut prev = PreviousCharacter::Other; // The previous character
|
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
|
// http://tools.ietf.org/html/rfc2616#section-2.2
|
||||||
match x {
|
match x {
|
||||||
13 => { // CR
|
13 => { // CR
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue