summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@spawned.biz>2024-04-25 00:32:14 +0200
committerJoel Klinghed <the_jk@spawned.biz>2024-04-25 00:32:14 +0200
commit8394910a7a57f6ddecf055f37931b476b8d1742d (patch)
tree4383502c5ec85e85517376e4397777a721a842ae
parent0f5874ea7c5b25152f448d8c46efee50b1c023ad (diff)
clippy: Follow most recommendations
It also tried to replace while let Some(arg) = args.next() { with: for arg in args.by_ref() { but that doesn't work on trait objects.
-rw-r--r--src/args.rs10
-rw-r--r--src/main.rs6
2 files changed, 8 insertions, 8 deletions
diff --git a/src/args.rs b/src/args.rs
index 919b41a..048a270 100644
--- a/src/args.rs
+++ b/src/args.rs
@@ -150,7 +150,7 @@ impl Parser for LongOnlyParser {
let mut ret = Vec::new();
let program = args.next();
while let Some(arg) = args.next() {
- if arg.len() >= 2 && arg.starts_with("-") {
+ if arg.len() >= 2 && arg.starts_with('-') {
if arg == "--" {
// All following arguments are just that.
while let Some(arg) = args.next() {
@@ -169,7 +169,7 @@ impl Parser for LongOnlyParser {
value = None;
}
if let Some(index) = options.long.get(name) {
- let ref mut option = options.options[*index];
+ let option = &mut options.options[*index];
match option.value_req {
ValueRequirement::None => {
if value.is_some() {
@@ -246,7 +246,7 @@ impl Parser for ShortAndLongParser {
value = None;
}
if let Some(index) = options.long.get(name) {
- let ref mut option = options.options[*index];
+ let option = &mut options.options[*index];
match option.value_req {
ValueRequirement::None => {
if value.is_some() {
@@ -270,10 +270,10 @@ impl Parser for ShortAndLongParser {
} else {
return Err(format!("unrecognized option '{}'", arg));
}
- } else if arg.starts_with("-") && arg.len() > 1 {
+ } else if arg.starts_with('-') && arg.len() > 1 {
for c in arg.get(1..).unwrap().chars() {
if let Some(index) = options.short.get(&c) {
- let ref mut option = options.options[*index];
+ let option = &mut options.options[*index];
let mut value = None;
match option.value_req {
ValueRequirement::None => {}
diff --git a/src/main.rs b/src/main.rs
index 4cfbcc7..de2ebb2 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -43,19 +43,19 @@ fn parse_args() -> Result<bool, String> {
let maybe_args = parser.run(&mut options, &mut std::env::args());
// help is special, check for it even if parser#run returned error.
- let ref help = options[help_idx];
+ let help = &options[help_idx];
if help.is_set() {
parser.print_help(&options);
return Ok(true);
}
let args = maybe_args?;
- let ref version = options[version_idx];
+ let version = &options[version_idx];
if version.is_set() {
println!("Version is 0.0.1");
return Ok(true);
}
- let ref verbose = options[verbose_idx];
+ let verbose = &options[verbose_idx];
println!("verbose: {}", verbose.is_set());
println!("args: {:?}", args.args);
Ok(false)