Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.

Add Enum for tuples #13

@norcalli

Description

@norcalli

It seems logical that (A, B) where A: Enum, B: Enum would be basically the same as a struct's derivation, which is a cartesian product. I don't think we're allowed to implement this ourselves as tuples are always a foreign type, but it could be implemented for up to some length of tuples in the crate.

I personally want this so that I can produce enums via this utility function I've made:

#[inline(always)]
pub fn enum_iter<E: enum_map::Enum>() -> impl DoubleEndedIterator<Item = E> + Clone {
    (0..E::LENGTH).map(|i| E::from_usize(i))
}

without having to nest the enum_iter calls if there's multiple which I want to produce from.

(Side note: the enum_iter function might also be useful to have put in.)

I could make an MR if it's an amenable feature to include.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions