这编译:
use std::num::pow;
pub fn main() {
let (tx, rx): (Sender<u64>, Receiver<u64>) = channel();
let square_tx = tx.clone();
let square = proc() {
let mut x = 1u;
loop {
square_tx.send(pow(2u64, x));
x += 1;
}
};
let printer = proc() {
loop { println!("Received: {}", rx.recv()); }
};
spawn(square);
spawn(printer);
}
但是,如果我注释掉spawn(square)
,则会引发以下错误:
error: unable to infer enough type information about `_`; type annotations required
let square = proc() {
^
没有产卵就无法推断出spawn()
a 的类型信息有什么特别之处?proc()