Skip to content

Instantly share code, notes, and snippets.

@DefectingCat
Created July 4, 2024 05:11
Show Gist options
  • Save DefectingCat/3e68ddb67969763df49423a9a5376f61 to your computer and use it in GitHub Desktop.
Save DefectingCat/3e68ddb67969763df49423a9a5376f61 to your computer and use it in GitHub Desktop.
rust at operator binding
fn main() {
let strs = ["hello world", "1", "hello", "world"];
let mut remaining: &[&str] = &strs;
while let [current, tail @ ..] = remaining {
println!("{} - {:?}", current, tail);
remaining = tail;
}
println!("The real strs {:?}", strs);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment