For instance, if I wanted to make an immutable mutable, I'd rather be explicit:
let x = "foo".to_string();
let mut x = x;
Much clearer than passing ownership to a block and returning the expression. fn consume_the_list(mut self) {
// self is mutable here
}
This is generally true for any other owned parameter, with the distinction that the `mut` applies to the parameter pattern and not the type. (i.e. `mut val: String`, not `val: mut String`). fn foo(x: u32) {}
fn foo(mut x: u32) {}
has a semantic difference to the consumer similar to fn foo(x: &u32) {}
fn foo(x: &mut u32) {}
but it does not. To avoid this confusion I'd rather do fn foo(x: u32) { let mut x = x; }Seems to compile just fine even with the edition set to 2015.