pub fn unbounded<T>() -> (Sender<T>, Receiver<T>)Expand description
Channel type definition based on features Use crossbeam::channel when crossbeam_channel feature is enabled, otherwise use std::sync::mpsc 基于 features 的 channel 类型定义 启用 crossbeam_channel feature 时使用 crossbeam::channel,否则使用 std::sync::mpsc 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());