diff --git a/.idea/discord.xml b/.idea/discord.xml deleted file mode 100644 index 59b11d1..0000000 --- a/.idea/discord.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 5171e1c..07d0986 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,11 +1,11 @@ +use may::go; +use may::sync::mpmc::{channel, Sender}; use num_cpus; -use std::fs::{OpenOptions}; -use std::io::prelude::*; use std::env; -use std::time::{Instant}; +use std::fs::OpenOptions; +use std::io::prelude::*; use std::io::BufWriter; -use may::sync::mpmc::{channel, Sender}; -use may::go; +use std::time::Instant; fn main() { may::config().set_workers(num_cpus::get()); @@ -40,7 +40,10 @@ fn main() { let prime = rx.recv().unwrap(); prime_count += 1; println!("\r{: <30}", prime); - print!("{} Primes/s", prime_count as f64/time_start.elapsed().as_secs_f64()); + print!( + "{} Primes/s", + prime_count as f64 / time_start.elapsed().as_secs_f64() + ); if let Err(e) = buffer.write(&format!("{}\n", prime).into_bytes()) { panic!(e); } @@ -48,6 +51,7 @@ fn main() { } fn get_primes(start: u64, incr: u64, tx: &Sender) { + println!("Hi, I'm a thread."); let mut num = start; loop { let mut is_prime = true; @@ -55,7 +59,7 @@ fn get_primes(start: u64, incr: u64, tx: &Sender) { num += incr; continue; } - for i in (3u64..&num/2).step_by(2) { + for i in (3u64..&num / 2).step_by(2) { if num % i == 0 { is_prime = false; } @@ -65,4 +69,4 @@ fn get_primes(start: u64, incr: u64, tx: &Sender) { } num += incr; } -} \ No newline at end of file +}