diff options
author | Neal H. Walfield <neal@pep.foundation> | 2022-01-18 13:27:45 +0100 |
---|---|---|
committer | Neal H. Walfield <neal@pep.foundation> | 2022-01-20 14:28:32 +0100 |
commit | a5c480ab9067f7b197e0b9f3d8a32bb5bc34eadf (patch) | |
tree | f8adbd2d0f4687ce962dddc36e56476fda02ff77 | |
parent | 92a56f22bf5ff20311fe0c325266204c4bb6c4b2 (diff) |
sq: Remove redundant predicate.
- `str::starts_with` already checks that the string is not empty.
Don't first check that the string is not empty.
-rw-r--r-- | sq/src/commands/certify.rs | 13 | ||||
-rw-r--r-- | sq/src/commands/revoke.rs | 13 | ||||
-rw-r--r-- | sq/src/sq.rs | 13 |
3 files changed, 18 insertions, 21 deletions
diff --git a/sq/src/commands/certify.rs b/sq/src/commands/certify.rs index c497d301..6a389064 100644 --- a/sq/src/commands/certify.rs +++ b/sq/src/commands/certify.rs @@ -125,13 +125,12 @@ pub fn certify(config: Config, m: &clap::ArgMatches) while let Some(name) = n.next() { let value = n.next().unwrap(); - let (critical, name) = if !name.is_empty() - && name.starts_with('!') - { - (true, &name[1..]) - } else { - (false, name) - }; + let (critical, name) = + if let Some(name) = name.strip_prefix('!') { + (true, name) + } else { + (false, name) + }; builder = builder.add_notation( name, diff --git a/sq/src/commands/revoke.rs b/sq/src/commands/revoke.rs index ad142692..167fe149 100644 --- a/sq/src/commands/revoke.rs +++ b/sq/src/commands/revoke.rs @@ -93,13 +93,12 @@ pub fn dispatch(config: Config, m: &clap::ArgMatches) -> Result<()> { while let Some(name) = n.next() { let value = n.next().unwrap(); - let (critical, name) = if !name.is_empty() - && name.starts_with('!') - { - (true, &name[1..]) - } else { - (false, name) - }; + let (critical, name) = + if let Some(name) = name.strip_prefix('!') { + (true, name) + } else { + (false, name) + }; notations.push( (critical, diff --git a/sq/src/sq.rs b/sq/src/sq.rs index 14600fed..ca95775d 100644 --- a/sq/src/sq.rs +++ b/sq/src/sq.rs @@ -509,13 +509,12 @@ fn main() -> Result<()> { while let Some(name) = n.next() { let value = n.next().unwrap(); - let (critical, name) = if !name.is_empty() - && name.starts_with('!') - { - (true, &name[1..]) - } else { - (false, name) - }; + let (critical, name) = + if let Some(name) = name.strip_prefix('!') { + (true, name) + } else { + (false, name) + }; notations.push( (critical, |