aboutsummaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
authorCorey Powell2021-06-02 19:24:08 +0000
committerCorey Powell2021-06-02 19:26:20 +0000
commitf0018280cbd6427d8102ccae7ec8c48ac046f922 (patch)
treeef38872f01bbab8f9e67afe101eb7a1cee0e2c00 /helix-term
parent7202953e69c6621a24c1609c5345b584dcd7530e (diff)
Refactored parse_args loop
Thanks @PabloMansanet
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/src/main.rs19
1 files changed, 9 insertions, 10 deletions
diff --git a/helix-term/src/main.rs b/helix-term/src/main.rs
index 432f2a20..8f29007c 100644
--- a/helix-term/src/main.rs
+++ b/helix-term/src/main.rs
@@ -60,19 +60,19 @@ fn parse_args(mut args: Args) -> Result<Args> {
iter.next(); // skip the program, we don't care about that
- loop {
- match iter.next() {
- Some(arg) if arg == "--" => break, // stop parsing at this point treat the remaining as files
- Some(arg) if arg == "--version" => args.display_version = true,
- Some(arg) if arg == "--help" => args.display_help = true,
- Some(arg) if arg.starts_with("--") => {
+ while let Some(arg) = iter.next() {
+ match arg.as_str() {
+ "--" => break, // stop parsing at this point treat the remaining as files
+ "--version" => args.display_version = true,
+ "--help" => args.display_help = true,
+ arg if arg.starts_with("--") => {
return Err(Error::msg(format!(
"unexpected double dash argument: {}",
arg
)))
}
- Some(arg) if arg.starts_with('-') => {
- let arg = arg.as_str().get(1..).unwrap().chars();
+ arg if arg.starts_with('-') => {
+ let arg = arg.get(1..).unwrap().chars();
for chr in arg {
match chr {
'v' => args.verbosity += 1,
@@ -82,8 +82,7 @@ fn parse_args(mut args: Args) -> Result<Args> {
}
}
}
- Some(arg) => args.files.push(PathBuf::from(arg)),
- None => break, // No more arguments to reduce
+ arg => args.files.push(PathBuf::from(arg)),
}
}