easy_rust
easy_rust copied to clipboard
Consider using into_iter instead of iter in the library example
The following example consumes the books instead of returning references. I think this fits better with the into_iter description.
impl Iterator for Library { type Item = String;
fn next(&mut self) -> Option<String> {
match self.books.pop() {
Some(book) => Some(book + " is found!"), // Rust allows String + &str
None => None,
}
}
}