[][src]Function tao_of_rust::ch02::binding::immutable_and_mutable

pub fn immutable_and_mutable()

不变与可变

Basic usage:

pub fn immutable_and_mutable() {
    let a = 1;  // 默认不可变
    // a = 2; // immutable and error: cannot assign twice to immutable variable
    let mut b = 2;  // 使用mut关键字声明可变绑定
    b = 3; // mutable
}
immutable_and_mutable();Run