Stuff the identity function does in Rust (2015)
bluss.github.io
bluss.github.io
Seems to compile just fine even with the edition set to 2015.
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; }While it's not really how it works, the closest valid Rust that comes to mind is:
const foo: fn(u32) = |mut x| {};
What rustdoc should be doing is stripping binding modes (`ref` and/or `mut`), or even whole patterns - with more complex patterns, like `(a, mut b): (T, U)`, it can be beneficial to keep `(a, b)` as a way to label the two components, but the `mut` is superfluous for documentation.said the old blind man