You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fn main() {
let (name, street) = ("John".to_str(), "Something".to_str());
match (name, street) {
(ref n, s) if *n == "...".to_str() => (),
_ => ()
}
}
The error message:
test.rs:4:17: 4:18 error: cannot bind by-move into a pattern guard
test.rs:4 (ref n, s) if *n == "...".to_str() => (),
^
error: aborting due to previous error
This forces you to use ref s to satisfy the compiler, but s is not used at all in the pattern guard! I think it this code should compile without ref s.
The text was updated successfully, but these errors were encountered:
Closing, this is just a fact of rustc right now. You're not allowed to move in a pattern with a guard. For relaxing these restrictions, rust-lang/rfcs#107 seems to do the trick.
The code:
The error message:
This forces you to use
ref s
to satisfy the compiler, buts
is not used at all in the pattern guard! I think it this code should compile withoutref s
.The text was updated successfully, but these errors were encountered: