Clippy fixes

This commit is contained in:
Mauro D
2024-01-08 19:31:34 +01:00
parent 598cba3b87
commit 4ff4c57e2c
8 changed files with 260 additions and 304 deletions
+1 -1
View File
@@ -170,7 +170,7 @@
{
"header": " 4 8 15 16 23 42, 4 8 15 16 23 42, 4 8 15 16 23 42, ",
"expected": {
"year": 1915,
"year": 2015,
"month": 8,
"day": 4,
"hour": 16,
+90 -90
View File
@@ -290,96 +290,6 @@ impl<'x> MessageStream<'x> {
}
}
#[cfg(test)]
mod tests {
use crate::parsers::MessageStream;
#[test]
fn decode_base64() {
for (encoded_str, expected_result) in [
("VGVzdA==", "Test"),
("WWU=", "Ye"),
("QQ==", "A"),
("cm8=", "ro"),
(
"QXJlIHlvdSBhIFNoaW1hbm8gb3IgQ2FtcGFnbm9sbyBwZXJzb24/",
"Are you a Shimano or Campagnolo person?",
),
(
"PCFET0NUWVBFIGh0bWw+CjxodG1sPgo8Ym9keT4KPC9ib2R5Pgo8L2h0bWw+Cg==",
"<!DOCTYPE html>\n<html>\n<body>\n</body>\n</html>\n",
),
(
"PCFET0NUWVBFIGh0bWw+CjxodG1sPg\no8Ym9ke\nT4KPC 9ib2R5Pg\n o8L2h0bWw+Cg==",
"<!DOCTYPE html>\n<html>\n<body>\n</body>\n</html>\n",
),
("w6HDqcOtw7PDug==", "áéíóú"),
("====", ""),
("w6HDq!cOtw7PDug=", ""),
("w6 HD qcOt", "áéí"),
("cmáé", ""),
("áé", ""),
("w\n6\nH\nD\nq\nc\nO\nt\nw\n7\n P\tD u g\n==", "áéíóú"),
("w6HDqcOtw7PDug==", "áéíóú"),
] {
assert_eq!(
super::base64_decode(encoded_str.as_bytes()).unwrap_or_default(),
expected_result.as_bytes(),
"Failed for {encoded_str:?}",
);
}
}
#[test]
fn decode_base64_mime() {
for (encoded_str, expected_result) in [
("VGVzdA==\r\n--boundary\n", "Test"),
(
"PCFET0NUWVBFIGh0bWw+CjxodG1sPg\no8Ym9ke\nT4KPC 9ib2R5Pg\n o8L2h0bWw+Cg==\r\n--boundary--\r\n",
"<!DOCTYPE html>\n<html>\n<body>\n</body>\n</html>\n",
),
("w6HDqcOtw7PDug==\r\n--boundary \n", "áéíóú"),
("w\n6\nH\nD\nq\nc\nO\nt\nw\n7\n P\tD u g\n==\r\n--boundary\n", "áéíóú"),
("w6HDqcOtw7PDug==--boundary", "áéíóú"),
(
"w6HDqcOtw7PDug==\n--boundary--",
"áéíóú",
),
(
"w\n6\nH\nD\nq\nc\nO\nt\nw\n7\n P\tD u g\n==\n--boundary",
"áéíóú",
),
] {
let mut s = MessageStream::new(encoded_str.as_bytes());
let (_, result) = s.decode_base64_mime(b"boundary");
assert_eq!(
result,
expected_result.as_bytes(),
"Failed for {encoded_str:?}",
);
}
}
#[test]
fn decode_base64_word() {
for (encoded_str, expected_result) in [
("w 6 H D q c O t w 7 P D u g== ?=", "áéíóú"),
("w6HDqcOtw7PDug==?=", "áéíóú"),
("w6HDqc\n Otw7PDug==?=", "áéíóú"),
("w6HDqcOtw7PDug================?=", "áéíóú"),
("?=", ""),
] {
let mut s = MessageStream::new(encoded_str.as_bytes());
assert_eq!(
s.decode_base64_word().unwrap(),
expected_result.as_bytes(),
"Failed for {encoded_str:?}",
);
}
}
}
/*
* Table adapted from Nick Galbreath's "High performance base64 encoder / decoder"
*
@@ -550,3 +460,93 @@ pub static BASE64_MAP: &[&[u32]] = &[
0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff,
],
];
#[cfg(test)]
mod tests {
use crate::parsers::MessageStream;
#[test]
fn decode_base64() {
for (encoded_str, expected_result) in [
("VGVzdA==", "Test"),
("WWU=", "Ye"),
("QQ==", "A"),
("cm8=", "ro"),
(
"QXJlIHlvdSBhIFNoaW1hbm8gb3IgQ2FtcGFnbm9sbyBwZXJzb24/",
"Are you a Shimano or Campagnolo person?",
),
(
"PCFET0NUWVBFIGh0bWw+CjxodG1sPgo8Ym9keT4KPC9ib2R5Pgo8L2h0bWw+Cg==",
"<!DOCTYPE html>\n<html>\n<body>\n</body>\n</html>\n",
),
(
"PCFET0NUWVBFIGh0bWw+CjxodG1sPg\no8Ym9ke\nT4KPC 9ib2R5Pg\n o8L2h0bWw+Cg==",
"<!DOCTYPE html>\n<html>\n<body>\n</body>\n</html>\n",
),
("w6HDqcOtw7PDug==", "áéíóú"),
("====", ""),
("w6HDq!cOtw7PDug=", ""),
("w6 HD qcOt", "áéí"),
("cmáé", ""),
("áé", ""),
("w\n6\nH\nD\nq\nc\nO\nt\nw\n7\n P\tD u g\n==", "áéíóú"),
("w6HDqcOtw7PDug==", "áéíóú"),
] {
assert_eq!(
super::base64_decode(encoded_str.as_bytes()).unwrap_or_default(),
expected_result.as_bytes(),
"Failed for {encoded_str:?}",
);
}
}
#[test]
fn decode_base64_mime() {
for (encoded_str, expected_result) in [
("VGVzdA==\r\n--boundary\n", "Test"),
(
"PCFET0NUWVBFIGh0bWw+CjxodG1sPg\no8Ym9ke\nT4KPC 9ib2R5Pg\n o8L2h0bWw+Cg==\r\n--boundary--\r\n",
"<!DOCTYPE html>\n<html>\n<body>\n</body>\n</html>\n",
),
("w6HDqcOtw7PDug==\r\n--boundary \n", "áéíóú"),
("w\n6\nH\nD\nq\nc\nO\nt\nw\n7\n P\tD u g\n==\r\n--boundary\n", "áéíóú"),
("w6HDqcOtw7PDug==--boundary", "áéíóú"),
(
"w6HDqcOtw7PDug==\n--boundary--",
"áéíóú",
),
(
"w\n6\nH\nD\nq\nc\nO\nt\nw\n7\n P\tD u g\n==\n--boundary",
"áéíóú",
),
] {
let mut s = MessageStream::new(encoded_str.as_bytes());
let (_, result) = s.decode_base64_mime(b"boundary");
assert_eq!(
result,
expected_result.as_bytes(),
"Failed for {encoded_str:?}",
);
}
}
#[test]
fn decode_base64_word() {
for (encoded_str, expected_result) in [
("w 6 H D q c O t w 7 P D u g== ?=", "áéíóú"),
("w6HDqcOtw7PDug==?=", "áéíóú"),
("w6HDqc\n Otw7PDug==?=", "áéíóú"),
("w6HDqcOtw7PDug================?=", "áéíóú"),
("?=", ""),
] {
let mut s = MessageStream::new(encoded_str.as_bytes());
assert_eq!(
s.decode_base64_word().unwrap(),
expected_result.as_bytes(),
"Failed for {encoded_str:?}",
);
}
}
}
+27 -27
View File
@@ -81,33 +81,6 @@ pub fn no_op(_bytes: &[u8]) -> String {
"".to_string()
}
#[cfg(test)]
mod tests {
use super::charset_decoder;
#[test]
#[allow(clippy::uninlined_format_args)]
fn decoder_charset() {
let inputs = [
"l8",
//"utf-8",
"utf-7",
//"US-Ascii",
"csgb18030",
"iso-8859-1",
"extended_unix_code_packed_format_for_japanese",
];
for input in inputs {
assert!(
charset_decoder(input.as_bytes()).is_some(),
"Failed for {}",
input
);
}
}
}
// Perfect hashing table for charset names
static CH_HASH: &[u32] = &[
765, 765, 765, 765, 765, 765, 765, 765, 765, 765, 765, 765, 765, 765, 765, 765, 765, 765, 765,
@@ -1648,3 +1621,30 @@ static FNC_MAP: &[for<'x> fn(&'x [u8]) -> String; 758] = &[
no_op,
decoder_gb18030,
];
#[cfg(test)]
mod tests {
use super::charset_decoder;
#[test]
#[allow(clippy::uninlined_format_args)]
fn decoder_charset() {
let inputs = [
"l8",
//"utf-8",
"utf-7",
//"US-Ascii",
"csgb18030",
"iso-8859-1",
"extended_unix_code_packed_format_for_japanese",
];
for input in inputs {
assert!(
charset_decoder(input.as_bytes()).is_some(),
"Failed for {}",
input
);
}
}
}
+86 -86
View File
@@ -276,92 +276,6 @@ pub fn text_to_html(input: &str) -> String {
String::from_utf8(result).unwrap()
}
#[cfg(test)]
mod tests {
use crate::decoders::html::{add_html_token, html_to_text, text_to_html};
#[test]
fn convert_text_to_html() {
let inputs = [
(
"hello\nworld\n",
"<html><body>hello<br/>world<br/></body></html>",
),
("using <>\n", "<html><body>using &lt;><br/></body></html>"),
];
for input in inputs {
assert_eq!(text_to_html(input.0), input.1);
}
}
#[test]
fn convert_html_to_text() {
let inputs = [
("<html>hello<br/>world<br/></html>", "hello\nworld\n"),
("<html>using &lt;><br/></html>", "using <>\n"),
("test <not br/>tag<br />", "test tag\n"),
("<>< ><tag\n/>>hello world< br \n />", ">hello world\n"),
(
concat!(
"<head><title>ignore head</title><not head>xyz</not head></head>",
"<h1>&lt;body&gt;</h1>"
),
"<body>",
),
(
concat!(
"<p>what is &heartsuit;?</p><p>&#x000DF;&Abreve;&#914;&gamma; ",
"don&apos;t hurt me.</p>"
),
"what is ♥?\nßĂΒγ don't hurt me.\n",
),
(
concat!(
"<!--[if mso]><style type=\"text/css\">body, table, td, a, p, ",
"span, ul, li {font-family: Arial, sans-serif!important;}</style><![endif]-->",
"this is <!-- <> < < < < ignore > -> here -->the actual<!--> text"
),
"this is the actual text",
),
(
" < p > hello < / p > < p > world < / p > !!! < br > ",
"hello\nworld\n!!!\n",
),
(
" <p>please unsubscribe <a href=#>here</a>.</p> ",
"please unsubscribe here.\n",
),
];
for input in inputs {
assert_eq!(html_to_text(input.0), input.1, "Failed for '{:?}'", input.0);
}
}
#[test]
fn convert_html_entity() {
let inputs = [
("&lt;", "<"),
("&#32;", " "),
("&#x20;", " "),
("&nbsp;", "\u{a0}"),
("&CounterClockwiseContourIntegral;", "∳"),
("&curvearrowright;", "↷"),
("&rarr;", "→"),
("&#xFFFFFFF;", "�"),
("&hmmm", "&hmmm"),
];
for input in inputs {
let mut result = String::with_capacity(input.0.len());
add_html_token(&mut result, input.0.as_bytes(), false);
assert_eq!(result, input.1, "Failed for '{:?}", input.0);
}
}
}
static ENTITY_HASH: &[u32; 260] = &[
18080, 18080, 18080, 18080, 18080, 18080, 18080, 18080, 18080, 18080, 18080, 18080, 18080,
18080, 18080, 18080, 18080, 18080, 18080, 18080, 18080, 18080, 18080, 18080, 18080, 18080,
@@ -1082,3 +996,89 @@ static ENTITY_MAP: &[u32; 18016] = &[
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x021B7,
];
#[cfg(test)]
mod tests {
use crate::decoders::html::{add_html_token, html_to_text, text_to_html};
#[test]
fn convert_text_to_html() {
let inputs = [
(
"hello\nworld\n",
"<html><body>hello<br/>world<br/></body></html>",
),
("using <>\n", "<html><body>using &lt;><br/></body></html>"),
];
for input in inputs {
assert_eq!(text_to_html(input.0), input.1);
}
}
#[test]
fn convert_html_to_text() {
let inputs = [
("<html>hello<br/>world<br/></html>", "hello\nworld\n"),
("<html>using &lt;><br/></html>", "using <>\n"),
("test <not br/>tag<br />", "test tag\n"),
("<>< ><tag\n/>>hello world< br \n />", ">hello world\n"),
(
concat!(
"<head><title>ignore head</title><not head>xyz</not head></head>",
"<h1>&lt;body&gt;</h1>"
),
"<body>",
),
(
concat!(
"<p>what is &heartsuit;?</p><p>&#x000DF;&Abreve;&#914;&gamma; ",
"don&apos;t hurt me.</p>"
),
"what is ♥?\nßĂΒγ don't hurt me.\n",
),
(
concat!(
"<!--[if mso]><style type=\"text/css\">body, table, td, a, p, ",
"span, ul, li {font-family: Arial, sans-serif!important;}</style><![endif]-->",
"this is <!-- <> < < < < ignore > -> here -->the actual<!--> text"
),
"this is the actual text",
),
(
" < p > hello < / p > < p > world < / p > !!! < br > ",
"hello\nworld\n!!!\n",
),
(
" <p>please unsubscribe <a href=#>here</a>.</p> ",
"please unsubscribe here.\n",
),
];
for input in inputs {
assert_eq!(html_to_text(input.0), input.1, "Failed for '{:?}'", input.0);
}
}
#[test]
fn convert_html_entity() {
let inputs = [
("&lt;", "<"),
("&#32;", " "),
("&#x20;", " "),
("&nbsp;", "\u{a0}"),
("&CounterClockwiseContourIntegral;", "∳"),
("&curvearrowright;", "↷"),
("&rarr;", "→"),
("&#xFFFFFFF;", "�"),
("&hmmm", "&hmmm"),
];
for input in inputs {
let mut result = String::with_capacity(input.0.len());
add_html_token(&mut result, input.0.as_bytes(), false);
assert_eq!(result, input.1, "Failed for '{:?}", input.0);
}
}
}
+21 -20
View File
@@ -312,6 +312,27 @@ impl<'x> MessageStream<'x> {
None
}
}
/*
* Adapted from Daniel Lemire's source:
* https://github.com/lemire/Code-used-on-Daniel-Lemire-s-blog/blob/master/2019/04/17/hexparse.cpp
*
*/
pub static HEX_MAP: &[i8] = &[
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 10,
11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
];
#[cfg(test)]
mod tests {
use crate::parsers::MessageStream;
@@ -468,23 +489,3 @@ mod tests {
}
}
}
/*
* Adapted from Daniel Lemire's source:
* https://github.com/lemire/Code-used-on-Daniel-Lemire-s-blog/blob/master/2019/04/17/hexparse.cpp
*
*/
pub static HEX_MAP: &[i8] = &[
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 10,
11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
];
+1 -1
View File
@@ -267,7 +267,7 @@ impl DateTime {
impl PartialOrd for DateTime {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.cmp(other).into()
Some(self.cmp(other))
}
}
+31 -76
View File
@@ -228,82 +228,6 @@ impl<'x> HeaderName<'x> {
}
}
#[cfg(test)]
mod tests {
use crate::{parsers::MessageStream, HeaderName};
#[test]
fn header_name_parse() {
let inputs = [
("From: ", HeaderName::From),
("receiVED: ", HeaderName::Received),
(" subject : ", HeaderName::Subject),
(
"X-Custom-Field : ",
HeaderName::Other("X-Custom-Field".into()),
),
(" T : ", HeaderName::Other("T".into())),
("mal formed: ", HeaderName::Other("mal formed".into())),
("MIME-version : ", HeaderName::MimeVersion),
];
for (input, expected_result) in inputs {
assert_eq!(
expected_result,
MessageStream::new(input.as_bytes())
.parse_header_name()
.unwrap(),
"Failed to parse '{input:?}'",
);
}
}
}
/*
type ParserFnc<'x> = fn(&mut MessageStream<'x>) -> crate::HeaderValue<'x>;
static HDR_PARSER: &[(bool, ParserFnc)] = &[
(false, MessageStream::parse_unstructured), // Subject = 0,
(false, MessageStream::parse_address), // From = 1,
(false, MessageStream::parse_address), // To = 2,
(false, MessageStream::parse_address), // Cc = 3,
(false, MessageStream::parse_date), // Date = 4,
(false, MessageStream::parse_address), // Bcc = 5,
(false, MessageStream::parse_address), // ReplyTo = 6,
(false, MessageStream::parse_address), // Sender = 7,
(true, MessageStream::parse_unstructured), // Comments = 8,
(false, MessageStream::parse_id), // InReplyTo = 9,
(true, MessageStream::parse_comma_separared), // Keywords = 10,
(true, MessageStream::parse_raw), // Received = 11,
(false, MessageStream::parse_id), // MessageId = 12,
(true, MessageStream::parse_id), // References = 13, (RFC 5322 recommends One)
(false, MessageStream::parse_id), // ReturnPath = 14,
(false, MessageStream::parse_raw), // MimeVersion = 15,
(false, MessageStream::parse_unstructured), // ContentDescription = 16,
(false, MessageStream::parse_id), // ContentId = 17,
(false, MessageStream::parse_comma_separared), // ContentLanguage = 18
(false, MessageStream::parse_unstructured), // ContentLocation = 19
(false, MessageStream::parse_unstructured), // ContentTransferEncoding = 20,
(false, MessageStream::parse_content_type), // ContentType = 21,
(false, MessageStream::parse_content_type), // ContentDisposition = 22,
(true, MessageStream::parse_address), // ResentTo = 23,
(true, MessageStream::parse_address), // ResentFrom = 24,
(true, MessageStream::parse_address), // ResentBcc = 25,
(true, MessageStream::parse_address), // ResentCc = 26,
(true, MessageStream::parse_address), // ResentSender = 27,
(true, MessageStream::parse_date), // ResentDate = 28,
(true, MessageStream::parse_id), // ResentMessageId = 29,
(false, MessageStream::parse_address), // ListArchive = 30,
(false, MessageStream::parse_address), // ListHelp = 31,
(false, MessageStream::parse_address), // ListId = 32,
(false, MessageStream::parse_address), // ListOwner = 33,
(false, MessageStream::parse_address), // ListPost = 34,
(false, MessageStream::parse_address), // ListSubscribe = 35,
(false, MessageStream::parse_address), // ListUnsubscribe = 36,
(true, MessageStream::parse_raw), // Other = 37,
];
*/
static HDR_HASH: &[u8] = &[
73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
@@ -461,3 +385,34 @@ static HDR_NAMES: &[&[u8]] = &[
b"",
b"mime-version",
];
#[cfg(test)]
mod tests {
use crate::{parsers::MessageStream, HeaderName};
#[test]
fn header_name_parse() {
let inputs = [
("From: ", HeaderName::From),
("receiVED: ", HeaderName::Received),
(" subject : ", HeaderName::Subject),
(
"X-Custom-Field : ",
HeaderName::Other("X-Custom-Field".into()),
),
(" T : ", HeaderName::Other("T".into())),
("mal formed: ", HeaderName::Other("mal formed".into())),
("MIME-version : ", HeaderName::MimeVersion),
];
for (input, expected_result) in inputs {
assert_eq!(
expected_result,
MessageStream::new(input.as_bytes())
.parse_header_name()
.unwrap(),
"Failed to parse '{input:?}'",
);
}
}
}
+3 -3
View File
@@ -134,15 +134,15 @@ impl<'x> MessageStream<'x> {
self.checkpoint();
match (self.next(), self.peek()) {
(Some(&a), Some(&&b)) if a == b'\r' && b == b'\n' => {
(Some(b'\r'), Some(b'\n')) => {
self.next();
false
}
(Some(&a), Some(&&b)) if a == b'-' && b == b'-' => {
(Some(b'-'), Some(b'-')) => {
self.next();
true
}
(Some(&a), _) if a == b'\n' => false,
(Some(b'\n'), _) => false,
(Some(&a), _) if a.is_ascii_whitespace() => {
self.skip_crlf();
false