]> git.lizzy.rs Git - rust.git/commitdiff
rustfmt: Move getopts::Options creation to its own function
authorKamal Marhubi <kamal@marhubi.com>
Sun, 10 Apr 2016 21:57:44 +0000 (17:57 -0400)
committerKamal Marhubi <kamal@marhubi.com>
Sun, 10 Apr 2016 21:57:44 +0000 (17:57 -0400)
src/bin/rustfmt.rs

index b65cbaa7f59c866309f240c41ac9309ecc7f644b..dba91612761522bc694700c0349c2a438ed56b3c 100644 (file)
@@ -134,7 +134,7 @@ fn update_config(config: &mut Config, matches: &Matches) -> Result<(), String> {
     }
 }
 
-fn execute() -> i32 {
+fn make_opts() -> Options {
     let mut opts = Options::new();
     opts.optflag("h", "help", "show this message");
     opts.optflag("V", "version", "show version information");
@@ -154,6 +154,12 @@ fn execute() -> i32 {
                  found reverts to the input file path",
                 "[Path for the configuration file]");
 
+    opts
+}
+
+fn execute() -> i32 {
+    let opts = make_opts();
+
     let matches = match opts.parse(env::args().skip(1)) {
         Ok(m) => m,
         Err(e) => {