Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
rust for loop
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
You can’t perform that action at this time.