Skip to content

Peekable's is_empty() has the wrong definition. #11785

@nham

Description

@nham

An iterator returns None if it is empty, but Peekable's is_empty is defined like this:

pub fn is_empty(&mut self) -> bool {
    self.peek().is_some()
}

https://github.com/mozilla/rust/blob/master/src/libstd/iter.rs#L1377

This needs to be changed to use is_none().

In fact, the code from test_peekable_is_empty() fails. It looks like this escaped detection because of a missing "#[test]"

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions