2 // ignore-emscripten no threads support
5 use std::sync::mpsc::{channel, Receiver};
7 fn periodical(n: isize) -> Receiver<bool> {
8 let (chan, port) = channel();
12 match chan.send(false) {
17 match chan.send(true) {
26 fn integers() -> Receiver<isize> {
27 let (chan, port) = channel();
28 thread::spawn(move|| {
42 let ints = integers();
43 let threes = periodical(3);
44 let fives = periodical(5);
46 match (ints.recv().unwrap(), threes.recv().unwrap(), fives.recv().unwrap()) {
47 (_, true, true) => println!("FizzBuzz"),
48 (_, true, false) => println!("Fizz"),
49 (_, false, true) => println!("Buzz"),
50 (i, false, false) => println!("{}", i)