通过例子学习Rust

22.2 冻结

When data is borrowed, it also freezes. Frozen data can't be modified via the original object, until all the references to it go out of scope.

fn main() { let mut _integer = 5i; { // Borrow `integer` let _ref_to_integer = &_integer; // Error! `integer` is frozen in this scope _integer = 4; // FIXME ^ Comment out this line // `ref_to_integer` goes out of scope } // Ok! `integer` is not frozen in this scope _integer = 4; }