Skip to content

Instantly share code, notes, and snippets.

@hyunsik
Last active October 13, 2015 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hyunsik/1fc20bbcf35571e67907 to your computer and use it in GitHub Desktop.
Save hyunsik/1fc20bbcf35571e67907 to your computer and use it in GitHub Desktop.
A skeleton code for Rust Iterator that does not consume items
pub struct TaskSetRefIterator<'a>
{
....
}
impl<'a> Iterator for TaskSetRefIterator<'a> {
type Item = &'a Task;
fn next(&mut self) -> Option<&'a Task> {
None
}
}
impl<'a> IntoIterator for &'a TaskSet {
type Item = &'a Task;
type IntoIter = TaskSetRefIterator<'a>;
fn into_iter(self) -> Self::IntoIter {
TaskSetRefIterator { ... }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment