diff options
author | Nora Widdecke <nora@sequoia-pgp.org> | 2021-04-07 20:23:44 +0200 |
---|---|---|
committer | Nora Widdecke <nora@sequoia-pgp.org> | 2021-04-09 13:13:59 +0200 |
commit | 19169b76117db8b1d81f1aafa64a5440d042803d (patch) | |
tree | bdd07c05920f6217bd1512e6dc56c1d8fb1da6bf /autocrypt | |
parent | 694680ae3b2192c102f1b9a4d342677545cac629 (diff) |
Lint: Use is_empty().
- https://rust-lang.github.io/rust-clippy/master/index.html#len_zero
- https://rust-lang.github.io/rust-clippy/master/index.html#comparison_to_empty
Diffstat (limited to 'autocrypt')
-rw-r--r-- | autocrypt/src/lib.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/autocrypt/src/lib.rs b/autocrypt/src/lib.rs index 5c2386cc..b3bebd65 100644 --- a/autocrypt/src/lib.rs +++ b/autocrypt/src/lib.rs @@ -239,7 +239,7 @@ impl AutocryptHeaders { // Return any error. let mut line = line?; - if line == "" { + if line.is_empty() { // End of headers. break; } @@ -252,7 +252,7 @@ impl AutocryptHeaders { // // See https://tools.ietf.org/html/rfc5322#section-2.2.3 while let Some(Ok(nl)) = next_line { - if nl.len() > 0 && (&nl[0..1] == " " || &nl[0..1] == "\t") { + if !nl.is_empty() && (&nl[0..1] == " " || &nl[0..1] == "\t") { line.push_str(&nl[..]); next_line = lines.next(); } else { @@ -315,7 +315,7 @@ impl AutocryptHeaders { } } - let critical = key.len() >= 1 && &key[0..1] == "_"; + let critical = !key.is_empty() && &key[0..1] == "_"; header.attributes.push(Attribute { critical, key: if critical { @@ -571,7 +571,7 @@ impl AutocryptSetupMessage { if k == "Passphrase-Format" { Some(v) } else { None } }) .collect::<Vec<&String>>(); - let format = if format.len() > 0 { + let format = if !format.is_empty() { // If there are multiple headers, then just silently take // the first one. Some(format[0].clone()) @@ -584,7 +584,7 @@ impl AutocryptSetupMessage { if k == "Passphrase-Begin" { Some(v) } else { None } }) .collect::<Vec<&String>>(); - let begin = if begin.len() > 0 { + let begin = if !begin.is_empty() { // If there are multiple headers, then just silently take // the first one. Some(begin[0].clone()) @@ -754,7 +754,7 @@ impl<'a> AutocryptSetupMessageParser<'a> { }) .collect::<Vec<&String>>(); - if prefer_encrypt.len() > 0 { + if !prefer_encrypt.is_empty() { // If there are multiple headers, then just // silently take the first one. Some(prefer_encrypt[0].clone()) |