Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn main() {
- let s = "abcd";
- let bytes = s.as_bytes();
- println!("{:?}", bytes.iter().enumerate().collect::<Vec<_>>());
- // prints [(0, 97), (1, 98), (2, 99), (3, 100)]
- println!("{:?}", bytes.iter().skip(1).enumerate().collect::<Vec<_>>());
- // prints [(0, 98), (1, 99), (2, 100)]
- println!("{:?}", bytes.iter().enumerate().skip(1).collect::<Vec<_>>());
- // prints [(1, 98), (2, 99), (3, 100)]
- }
Add Comment
Please, Sign In to add comment