easy_rust icon indicating copy to clipboard operation
easy_rust copied to clipboard

Consider using into_iter instead of iter in the library example

Open danj opened this issue 3 years ago • 0 comments

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,
    }
}

}

danj avatar Oct 19 '21 18:10 danj