Skip to content

core::ops::Range is Copyable but not Cloneable #21431

Closed
@alexchandel

Description

@alexchandel

Range is an iterator, copyable when its index is copyable, but not cloneable even if its index is both copyable and cloneable. This interferes with traits like itertools::Product, which require cloneable iterators.

Specifically, this prevents one from doing something like:

iproduct!(0us..10, 0us..10).map(|x, y| x*y).all(|z| z >= 0)

which fails with the expected error:

<itertools macros>:2:12: 2:37 error: the trait `core::clone::Clone` is not implemented for the type `core::ops::Range<usize>`
<itertools macros>:2 { let it = $ crate :: Product :: new ( $ I , $ J ) ; 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