Skip to content

Instantly share code, notes, and snippets.

@uzimith
Last active August 8, 2017 03:00
Show Gist options
  • Save uzimith/f5e2c99c7af0222d9516613b5887b1a0 to your computer and use it in GitHub Desktop.
Save uzimith/f5e2c99c7af0222d9516613b5887b1a0 to your computer and use it in GitHub Desktop.
fn main() {
let mut vec = vec!("1", "1");
let first = vec.pop();
let second = vec.pop();
match (first, second) {
(Some(a), Some(b)) if a == b => print!("yes"),
(Some(_), Some(_)) => print!("hi"),
_ => print!("no")
}
}
// yes
fn main() {
let mut vec = vec!("1".to_string(), "1".to_string());
let first = vec.pop();
let second = vec.pop();
match (first, second) {
(Some(a), Some(b)) if a == b => print!("yes"),
(Some(_), Some(_)) => print!("hi"),
_ => print!("no")
}
}
/*
error[E0008]: cannot bind by-move into a pattern guard
--> src/main.rs:6:15
|
6 | (Some(a), Some(b)) if a == b => print!("yes"),
| ^ moves value into pattern guard
error[E0008]: cannot bind by-move into a pattern guard
--> src/main.rs:6:24
|
6 | (Some(a), Some(b)) if a == b => print!("yes"),
| ^ moves value into pattern guard
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment