Skip to content

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

@danj

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

}

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