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
If there already is an issue for this, I apologize. I couldn't find one, but searching for this is a bit hard.
Right now, the borrow checker does not allow a borrow of a variable in the else branch if the let binding borrows the variable.
Example:
let mut m = HashMap::<i64, bool>::new(); if let Some(x) = m.get(&10) { // do something... } else { m.insert(10, true); }
The m.insert is invalid, because the borrow checker assumes an active borrow for the hashmap.
m.insert
The Some(x) binding is not in scope anymore, though, and there's no way to access x, so this should be allowed.
Some(x)
x
The text was updated successfully, but these errors were encountered:
I believe this is covered by rust-lang/rfcs#811
Sorry, something went wrong.
@sfackler yup, appear to be.
Closing as duplicate...
No branches or pull requests
If there already is an issue for this, I apologize. I couldn't find one, but searching for this is a bit hard.
Right now, the borrow checker does not allow a borrow of a variable in the else branch if the let binding borrows the variable.
Example:
The
m.insert
is invalid, because the borrow checker assumes an active borrow for the hashmap.The
Some(x)
binding is not in scope anymore, though, and there's no way to accessx
, so this should be allowed.The text was updated successfully, but these errors were encountered: