Function crossbeam_channel::unbounded
source · Expand description
Creates a channel of unbounded capacity.
This channel has a growable buffer that can hold any number of messages at a time.
Examples
use std::thread;
use crossbeam_channel::unbounded;
let (s, r) = unbounded();
// Computes the n-th Fibonacci number.
fn fib(n: i32) -> i32 {
if n <= 1 {
n
} else {
fib(n - 1) + fib(n - 2)
}
}
// Spawn an asynchronous computation.
thread::spawn(move || s.send(fib(20)).unwrap());
// Print the result of the computation.
println!("{}", r.recv().unwrap());