We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
self
When a &mut self method is called, the receiver is mutably borrowed before the arguments are evaluated, so the following program does not compile:
&mut self
fn main() { let mut vec = vec![1, 2, 3]; vec.push(vec.len()); assert_eq!(vec, vec![1, 2, 3, 4]); }
But when the argument explicitly evaluated before the call in a let statement, is compiles just fine:
let
fn main() { let mut vec = vec![1, 2, 3]; let vec_len = vec.len(); vec.push(vec_len); assert_eq!(vec, vec![1, 2, 3, 3]); }
I am not sure if there is a good reason for the first program to be rejected, I would expect e1(e2) to be equivalent to { let x = e2; e1(x) }.
e1(e2)
{ let x = e2; e1(x) }
The text was updated successfully, but these errors were encountered:
I believe this sort of thing is intended to be resolved by SEME regions: rust-lang/rfcs#396
Sorry, something went wrong.
In particular, motivating example 3: https://github.com/zwarich/rfcs/blob/seme-regions/active/0000-seme-regions.md
self.x
No branches or pull requests
When a
&mut self
method is called, the receiver is mutably borrowed before the arguments are evaluated, so the following program does not compile:But when the argument explicitly evaluated before the call in a
let
statement, is compiles just fine:I am not sure if there is a good reason for the first program to be rejected, I would expect
e1(e2)
to be equivalent to{ let x = e2; e1(x) }
.The text was updated successfully, but these errors were encountered: