summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-09-27 14:30:04 +0300
committerLars Wirzenius <liw@sequoia-pgp.org>2021-09-30 08:31:08 +0300
commit1b70924cc49ea1aa36f06acba8561f125439ca1b (patch)
tree66a9d5c7ae3db0467b1f3420c7cf2ef541de5bcb
parentd54c6eeda41a2d5d272f8bd24b616aca646b683f (diff)
Use .starts_with instead of .chars().next()
Instead of this: name.chars().next() == Some('!') use this: name.starts_with('!') It's more to the point, and does not require the reader to reason about iterators and possible values returneed by .next(). Found by clippy lint chars_next_cmp: https://rust-lang.github.io/rust-clippy/master/index.html#chars_next_cmp
-rw-r--r--sq/src/commands/certify.rs2
-rw-r--r--sq/src/sq.rs2
2 files changed, 2 insertions, 2 deletions
diff --git a/sq/src/commands/certify.rs b/sq/src/commands/certify.rs
index 746737b8..98c28402 100644
--- a/sq/src/commands/certify.rs
+++ b/sq/src/commands/certify.rs
@@ -124,7 +124,7 @@ pub fn certify(config: Config, m: &clap::ArgMatches)
let value = n.next().unwrap();
let (critical, name) = if !name.is_empty()
- && Some('!') == name.chars().next()
+ && name.starts_with('!')
{
(true, &name[1..])
} else {
diff --git a/sq/src/sq.rs b/sq/src/sq.rs
index 1c692ec0..37146bcc 100644
--- a/sq/src/sq.rs
+++ b/sq/src/sq.rs
@@ -501,7 +501,7 @@ fn main() -> Result<()> {
let value = n.next().unwrap();
let (critical, name) = if !name.is_empty()
- && Some('!') == name.chars().next()
+ && name.starts_with('!')
{
(true, &name[1..])
} else {