你能提供闭包比当前函数更长的任何例子吗?

时间:2016-12-05 08:57:41

标签: concurrency rust closures

根据Rust书籍,以下代码可能导致closure may outlive the current function错误:

use std::thread;

fn main() {
    let x = 1;
    thread::spawn(|| {
        println!("x is {}", x);
    });
}

认为闭包何时以及如何比现在的功能发生更为抽象是抽象的;你能提供任何例子或规格吗?

0 个答案:

没有答案