Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created December 2, 2019 23:05
Show Gist options
  • Save rust-play/e95ba50687a3bebdac57e126117fe3ae to your computer and use it in GitHub Desktop.
Save rust-play/e95ba50687a3bebdac57e126117fe3ae to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
fn main() {
let u: Vec<usize> = vec![];
let v = vec![0, 1, 2];
let w = vec![0, 1, 2, 3, 4, 5];
let a = u.get(1..).unwrap_or(&[]).chunks(3).next().unwrap_or(&[]);
let b = v.get(1..).unwrap_or(&[]).chunks(3).next().unwrap_or(&[]);
let c = w.get(1..).unwrap_or(&[]).chunks(3).next().unwrap_or(&[]);
println!("{:?}\n{:?}\n{:?}", a, b, c);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment