Created
August 23, 2015 23:18
-
-
Save anonymous/ff1968fe1db9a605cd79 to your computer and use it in GitHub Desktop.
Shared via Rust Playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
let g = vec![1, 5, 6, 9, 8]; | |
let r = 7; | |
let mut i = g.iter().enumerate().peekable(); | |
while let Some((index, lhs_val)) = i.next() { | |
let lookahead = i.peek(); | |
println!("{}, {} with lookahead {:?}", index, lhs_val, lookahead); | |
} | |
// resulting iteration would be | |
// 0, 1 and includes 1, 5 & 2, 6 | |
// 3, 9 | |
// 4, 8 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment