enum_map! is unusable as a const initializer, and the array field being private makes manual initialization impossible too

Created by: bill-myers

enum_map! is probably not fixable in stable Rust without the unstable const fn support, unless there's some clever approach I'm not seeing.

However, making the field public would allow to manually do it.

There's also the possibility of writing an enum_with_map! macro that would create both an enum and an enum map const (by just writing both the variants and the array items in the same order as provided by the user), which is easy and might be good enough in practice.

Possible implementation of such a macro (after changing EnumMap to be a tuple struct with a public array field):

#[macro_export]
macro_rules! enum_with_map {
	{$(#[$m:meta])* enum $e:ident, const $n:ident : EnumMap<_, $d:ty> = {$($k:ident => $v:expr),*};} => {
        $(#[$m])* #[derive(EnumMap)] enum $e {
            $($k),*
        }

        const $n: EnumMap<$e, $d> = EnumMap([
            $($v),*
        ]);
    };
}