use std::{thread, time::Duration};
fn sleepsort<I: Iterator<Item = u32>>(nums: I) {
let threads: Vec<_> = nums
.map(|n| {
thread::spawn(move || {
thread::sleep(Duration::from_millis(n.into()));
println!("{}", n);
})
})
.collect();
for t in threads {
let _ = t.join();
}
}
fn main() {
sleepsort(std::env::args().skip(1).map(|s| s.parse().unwrap()));
}-
Notifications
You must be signed in to change notification settings - Fork 0
tonymushah/sleep_sort_rs_test
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
About
Just testing the sleep sort algorithm in rust
Topics
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published