Why does Rust allow upgrading/downgrading mutability?

后端 未结 0 1504
广开言路
广开言路 2021-02-04 09:42

In rust, you can upgrade an immutable variable:

let v = Vec::new(); // Immutable
let mut v = v;      // Mutable
v.push("hi");       // Succeeds
<         


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