Skip to content

tonymushah/sleep_sort_rs_test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sleep Sort in Rust

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()));
}

About

Just testing the sleep sort algorithm in rust

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages