From a696c1e949b3c3906737bf74bd552dec2cc35eb7 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Wed, 14 Mar 2018 13:51:00 +0100 Subject: Separate args from passwords on the command line. --- src/main.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 9450068..9e18a85 100644 --- a/src/main.rs +++ b/src/main.rs @@ -111,12 +111,11 @@ fn check(pw: Password) -> Result<(), Box<::std::error::Error>> { } fn main() { - let mut passwords = Vec::new(); - for arg in env::args().skip(1) { - passwords.push(Password::new(&arg)); - }; + let (_args, passwords) : (Vec, Vec) = env::args() + .skip(1) + .partition(|arg| arg.starts_with('-')); for pw in passwords { - check(pw).unwrap(); + check(Password::new(&pw)).unwrap(); } } -- cgit v1.2.3