Sorting algorithms/Sleep sort: Difference between revisions

→‎{{header|Rust}}: updated for Rust 1.0 final
(→‎{{header|Rust}}: slight simplification, eliminates an allocation)
(→‎{{header|Rust}}: updated for Rust 1.0 final)
Line 1,170:
 
fn sleepsort<I: Iterator<Item=u32>>(nums: I) {
let mut threads: Vec<_> = Vec::newnums.map();|n|
for n in nums thread::spawn(move || {
threads.push(thread::scoped(move || {
thread::sleep_ms(n);
println!("{}", n); })).collect();
for t in threads }){ t.join(); }
}
}
 
Anonymous user