What's new in Rust 2021
closure can choose to only capture some namespace
previously closure cannot just capture tom.title, it needs to capture the entire Emploee structure
struct Emploee {
name: String,
title: String,
}
fn main() {
let tom = Employee {
name: "Tom".into(),
title: "Engineer".into(),
};
drop(tom.name);
println!("title: {}", tom.title);
let c = || println!("{}", tom.title);
c();
}
feature resolver
no need to compile all features for a crate, can compile separately
prelude now includes tryinto, tryfrom, fromiterator, so we no longer need use std::convert::TryFrom;