diff --git a/src/main.rs b/src/main.rs
index bf4fe27..b19bf4f 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -16,17 +16,33 @@
* along with this program. If not, see .
*/
-use std::env;
+//use std::env;
+use structopt::StructOpt;
+use std::path::PathBuf;
use std::collections::VecDeque;
+#[derive(StructOpt)]
+struct Opt {
+ #[structopt(short, long)]
+ verbose:bool,
+ //#[structopt(short, long)]
+ //import:Option,
+ n:usize,
+}
+
fn main() {
- let args:Vec = env::args().collect();
+ //let args:Vec = env::args().collect();
+ let opts = Opt::from_args();
// get the first `n` primes
- let n:usize = args[1].parse().unwrap();
+ //let n:usize = args[1].parse().unwrap();
+ let n = opts.n;
let mut primes:VecDeque = VecDeque::with_capacity(n);
// first prime
- println!("{}", 2);
+ if opts.verbose
+ {
+ println!("{}", 2);
+ }
primes.push_back(2);
let mut candidate:u64 = 3;
@@ -46,9 +62,17 @@ fn main() {
if is_prime
{
- println!("{}", candidate);
+ if opts.verbose
+ {
+ println!("{}", candidate);
+ }
primes.push_back(candidate);
}
candidate += 2;
}
+
+ if !opts.verbose
+ {
+ println!("{}", primes.back().unwrap());
+ }
}