Skip to content

Consider using into_iter instead of iter in the library example #140

Description

@danj

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

}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions