What is the logic behind freezing mutable borrowed variables in Rust?

后端 未结 0 689
一向
一向 2021-02-04 12:52

In a single mutable reference, there is a concept of freezing the values:

fn main() {
    let mut x = 5;

    let y = &mut x; // freeze
    *y *= 2; // unfree         


        
相关标签:
回答
  • 消灭零回复
提交回复
热议问题