Guest User

Untitled

a guest
Jun 21st, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. fn main() {
  2. let vs = vec!["1", "2"];
  3.  
  4. // this range slice is ok, since it's within the bounds of the vec length
  5. let vs_slice = &vs[0..2];
  6. println!("{:?}", vs_slice);
  7.  
  8. // but this will panic!
  9. let vs_slice = &vs[0..3];
  10. println!("{:?}", vs_slice);
  11. }
Add Comment
Please, Sign In to add comment