Skip to content

Const generics iterator candidates #547

Open
@conradludgate

Description

@conradludgate

Discussed in #546 where I've written an alternative to tuple_combinations, array_combinations which is an iterator that outputs [T; N]. This feature requires const generics which were introduced in Rust 1.51. It was suggested that we can bump the MSRV in a major release (ie itertools 0.11) but it would be sensible to add more features along side.

This crate uses a lot of tuples where arrays make more sense. Tuples are good when you have multiple types (eg cartesian product or zip) but when you have a collection of the same type, a slice/vec/array makes more sense.

Here's a list of functions that seem to qualify using arrays:

  • circular_tuple_windows -> circular_array_windows
  • tuples -> arrays
  • collect_tuple -> collect_array
  • next_tuple -> next_array

These all work on a single iterator over the single I::Item type, and since these use tuples, the number of elements is known at compile time, making them perfect for using arrays instead of tuples.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions