Skip to content

RFC: Make Take and Skip iterators DoubleEndedIterators when built from ExactSize iterators #12784

Closed
@ghost

Description

Right now, the following does not work:

fn main() {
    let v = &[1, 2, 3, 4, 5];
    for x in v.iter().take(3).rev() {
        println!("{:}", x);
    }
}

test.rs:3:11: 3:33 error: type std::iter::Take<std::vec::Items<,<generic integer #4>>> does not implement any method in scope named rev
test.rs:3 for x in v.iter().take(3).rev() {

This would require adding an extra field to both of the iterators so I'm not sure if it's worth it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions