summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSophie Tauchert <999eagle@999eagle.moe>2021-01-13 10:54:54 +0100
committerAbin Simon <abinsimon10@gmail.com>2021-01-14 22:24:26 +0530
commit2a93ce3a6e7cd7cc305bff1bf55a696ff911c44c (patch)
tree5c77aef447f15a8b668e864cc199a1b77e7a57ef
parent1107a259b3944d0452d00abe61d648de6d6257f1 (diff)
Invert order of flag parsing to return early
-rw-r--r--src/flags.rs14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/flags.rs b/src/flags.rs
index 0b3d30e..676a84f 100644
--- a/src/flags.rs
+++ b/src/flags.rs
@@ -111,21 +111,19 @@ where
/// The configuration file's Yaml is read in any case, to be able to check for errors and print
/// out warnings.
fn configure_from(matches: &ArgMatches, config: &Config) -> T {
- let mut result: T = Default::default();
-
- if let Some(value) = Self::from_config(config) {
- result = value;
+ if let Some(value) = Self::from_arg_matches(matches) {
+ return value;
}
if let Some(value) = Self::from_environment() {
- result = value;
+ return value;
}
- if let Some(value) = Self::from_arg_matches(matches) {
- result = value;
+ if let Some(value) = Self::from_config(config) {
+ return value;
}
- result
+ Default::default()
}
/// The method to implement the value fetching from command line parameters.