Created
July 1, 2019 18:42
-
-
Save fcracker79/e51b6bcb123188627a3fdb008e6c38ef to your computer and use it in GitHub Desktop.
rust for loop
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
struct NiceStructure<'a, T: Iterator<Item=&'a u32>> { | |
it: T | |
} | |
fn f<'a, T: Iterator<Item=&'a u32>>(it: &mut NiceStructure<'a, T>) { | |
// This does not work: cannot move out of borrowed content | |
// for x in it.it { | |
// println!("Element {:?}", x); | |
// } | |
// This works | |
while let Some(x) = it.it.next() { | |
println!("Element {:?}", x) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment