Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn main() {
- let vs = vec!["1", "2"];
- // this range slice is ok, since it's within the bounds of the vec length
- let vs_slice = &vs[0..2];
- println!("{:?}", vs_slice);
- // but this will panic!
- let vs_slice = &vs[0..3];
- println!("{:?}", vs_slice);
- }
Add Comment
Please, Sign In to add comment