Guest User

Untitled

a guest
Aug 17th, 2019
63
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #![feature(repeat_generic_slice)]
  2.  
  3. fn main() {
  4. let v: Vec<u8> = [10, 20, 30, 40].repeat(5);
  5.  
  6. let a: Vec<u8> = v.iter().copied().step_by(4).collect();
  7. let r: Vec<u8> = v.iter().copied().skip(1).step_by(4).collect();
  8. let g: Vec<u8> = v.iter().copied().skip(2).step_by(4).collect();
  9. let b: Vec<u8> = v.iter().copied().skip(3).step_by(4).collect();
  10.  
  11. println!("{:?}\n", v);
  12. println!("{:?}", a);
  13. println!("{:?}", r);
  14. println!("{:?}", g);
  15. println!("{:?}", b);
  16. }
RAW Paste Data