Thanks Clippy!
This commit is contained in:
parent
cc8551e357
commit
f5f04ea5e3
|
@ -54,10 +54,7 @@ pub fn Standardized_tag(input: &[u8]) -> IResult<&[u8], &[u8]> {
|
|||
///
|
||||
/// dcontent = %d33-90 / %d94-126
|
||||
pub fn is_dcontent(byte: u8) -> bool {
|
||||
match byte {
|
||||
33..=90 | 94..=126 => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(byte, 33..=90 | 94..=126)
|
||||
}
|
||||
|
||||
/// Representing a decimal integer value in the range 0 through 255
|
||||
|
|
|
@ -354,10 +354,7 @@ pub fn esmtp_keyword(input: &[u8]) -> IResult<&[u8], &[u8]> {
|
|||
/// esmtp-value = 1*(%d33-60 / %d62-126)
|
||||
pub fn esmtp_value(input: &[u8]) -> IResult<&[u8], &[u8]> {
|
||||
fn is_value_character(byte: u8) -> bool {
|
||||
match byte {
|
||||
33..=60 | 62..=126 => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(byte, 33..=60 | 62..=126)
|
||||
}
|
||||
|
||||
take_while1(is_value_character)(input)
|
||||
|
@ -494,10 +491,7 @@ pub fn QcontentSMTP(input: &[u8]) -> IResult<&[u8], &[u8]> {
|
|||
/// quoted-pairSMTP = %d92 %d32-126
|
||||
pub fn quoted_pairSMTP(input: &[u8]) -> IResult<&[u8], &[u8]> {
|
||||
fn is_ascii_bs_or_sp(byte: u8) -> bool {
|
||||
match byte {
|
||||
32..=126 => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(byte, 32..=126)
|
||||
}
|
||||
|
||||
let parser = tuple((tag("\\"), take_while_m_n(1, 1, is_ascii_bs_or_sp)));
|
||||
|
@ -512,10 +506,7 @@ pub fn quoted_pairSMTP(input: &[u8]) -> IResult<&[u8], &[u8]> {
|
|||
///
|
||||
/// qtextSMTP = %d32-33 / %d35-91 / %d93-126
|
||||
pub fn is_qtextSMTP(byte: u8) -> bool {
|
||||
match byte {
|
||||
32..=33 | 35..=91 | 93..=126 => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(byte, 32..=33 | 35..=91 | 93..=126)
|
||||
}
|
||||
|
||||
/// String = Atom / Quoted-string
|
||||
|
|
|
@ -421,17 +421,11 @@ pub mod addr_spec {
|
|||
/// dtext = %d33-90 / %d94-126 / obs-dtext
|
||||
pub fn dtext(input: &[u8]) -> IResult<&[u8], &[u8]> {
|
||||
fn is_a(byte: u8) -> bool {
|
||||
match byte {
|
||||
33..=90 => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(byte, 33..=90)
|
||||
}
|
||||
|
||||
fn is_b(byte: u8) -> bool {
|
||||
match byte {
|
||||
94..=126 => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(byte, 94..=126)
|
||||
}
|
||||
|
||||
let parser = alt((
|
||||
|
@ -540,10 +534,7 @@ pub mod obsolete {
|
|||
///
|
||||
/// obs-NO-WS-CTL = %d1-8 / %d11 / %d12 / %d14-31 / %d127
|
||||
pub fn is_obs_NO_WS_CTL(byte: u8) -> bool {
|
||||
match byte {
|
||||
1..=8 | 11 | 12 | 14..=31 | 127 => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(byte, 1..=8 | 11 | 12 | 14..=31 | 127)
|
||||
}
|
||||
|
||||
/// obs-qtext = obs-NO-WS-CTL
|
||||
|
|
|
@ -31,7 +31,7 @@ pub fn Greeting(input: &[u8]) -> IResult<&[u8], GreetingType> {
|
|||
domain: domain.to_owned(),
|
||||
text: maybe_text
|
||||
.map(|str| str.to_string())
|
||||
.unwrap_or("".to_string()),
|
||||
.unwrap_or_else(|| "".to_string()),
|
||||
},
|
||||
),
|
||||
map(
|
||||
|
@ -50,18 +50,18 @@ pub fn Greeting(input: &[u8]) -> IResult<&[u8], GreetingType> {
|
|||
text: {
|
||||
let mut res = maybe_text
|
||||
.map(|str| format!("{}\n", str))
|
||||
.unwrap_or("\n".to_string());
|
||||
.unwrap_or_else(|| "\n".to_string());
|
||||
|
||||
for text in more_text {
|
||||
let text = text
|
||||
.map(|str| format!("{}\n", str))
|
||||
.unwrap_or("\n".to_string());
|
||||
.unwrap_or_else(|| "\n".to_string());
|
||||
res.push_str(&text);
|
||||
}
|
||||
|
||||
let text = moar_text
|
||||
.map(|str| format!("{}", str))
|
||||
.unwrap_or("".to_string());
|
||||
.map(|str| str.to_string())
|
||||
.unwrap_or_else(|| "".to_string());
|
||||
res.push_str(&text);
|
||||
|
||||
res
|
||||
|
@ -80,10 +80,7 @@ pub fn Greeting(input: &[u8]) -> IResult<&[u8], GreetingType> {
|
|||
/// textstring = 1*(%d09 / %d32-126)
|
||||
pub fn textstring(input: &[u8]) -> IResult<&[u8], &str> {
|
||||
fn is_value(byte: u8) -> bool {
|
||||
match byte {
|
||||
9 | 32..=126 => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(byte, 9 | 32..=126)
|
||||
}
|
||||
|
||||
let (remaining, parsed) = map_res(take_while1(is_value), std::str::from_utf8)(input)?;
|
||||
|
|
|
@ -73,10 +73,7 @@ pub fn ehlo_ok_rsp(input: &[u8]) -> IResult<&[u8], EhloOkResp> {
|
|||
/// ehlo-greet = 1*(%d0-9 / %d11-12 / %d14-127)
|
||||
pub fn ehlo_greet(input: &[u8]) -> IResult<&[u8], &str> {
|
||||
fn is_valid_character(byte: u8) -> bool {
|
||||
match byte {
|
||||
0..=9 | 11..=12 | 14..=127 => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(byte, 0..=9 | 11..=12 | 14..=127)
|
||||
}
|
||||
|
||||
map_res(take_while1(is_valid_character), std::str::from_utf8)(input)
|
||||
|
@ -96,7 +93,7 @@ pub fn ehlo_line(input: &[u8]) -> IResult<&[u8], (&str, Vec<&str>)> {
|
|||
|
||||
let (remaining, (ehlo_keyword, ehlo_params)) = parser(input)?;
|
||||
|
||||
Ok((remaining, (ehlo_keyword, ehlo_params.unwrap_or(vec![]))))
|
||||
Ok((remaining, (ehlo_keyword, ehlo_params.unwrap_or_default())))
|
||||
}
|
||||
|
||||
/// Additional syntax of ehlo-params depends on ehlo-keyword
|
||||
|
@ -119,10 +116,7 @@ pub fn ehlo_keyword(input: &[u8]) -> IResult<&[u8], &[u8]> {
|
|||
/// ehlo-param = 1*(%d33-126)
|
||||
pub fn ehlo_param(input: &[u8]) -> IResult<&[u8], &str> {
|
||||
fn is_valid_character(byte: u8) -> bool {
|
||||
match byte {
|
||||
33..=126 => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(byte, 33..=126)
|
||||
}
|
||||
|
||||
map_res(take_while1(is_valid_character), std::str::from_utf8)(input)
|
||||
|
|
Loading…
Reference in New Issue