Skip to content

Why does izip!(iter) not return 1-tuples? #267

Open
@ExpHP

Description

@ExpHP

When given a single Iterator, izip just does into_iter.

I know it has been like this from the very beginning, but I never understood why. There isn't really much of a use case for calling izip with one iterable in real code ; the only time this ever happens is when another macro uses izip, in which case the lack of 1-tuples invariably just causes trouble.

Given some matched repetition like $($ident)+, I see no straightforward way to construct a pattern for these items.

#[macro_use] extern crate itertools;

macro_rules! fmt_columns {
    ($fmt:expr, $($c:ident),+ $(,)*) => {
        izip!($($c),+)
            // nope, matches A with (a,)
            // .map(|($($c,)+)| format!($fmt, $($c),+))
            
            // nope. (a) is not a valid pattern
            // .map(|($($c),+)| format!($fmt, $($c),+))
            
            // ???
    }
}

(I could've sworn this also used to be a problem with types as well, but it appears that (T) is a valid type in the latest stable)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions