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

Commit 41493d4

Browse files
committed
Allow storing V with #[derive(Enum)]
enum-map reserves __EnumMapInternalV for this purpose. This is not a part of stable API, and it's only necessary due to not having stable def_site hygiene.
1 parent 4082f9f commit 41493d4

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

enum-map-derive/src/derive_enum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl EnumGenerator {
3737
quote! {
3838
#[automatically_derived]
3939
impl ::enum_map::Enum for #name {
40-
type Array<V> = [V; #length];
40+
type Array<__EnumMapInternalV> = [__EnumMapInternalV; #length];
4141

4242
#[inline]
4343
fn from_usize(value: ::enum_map::usize) -> Self {

enum-map-derive/src/derive_struct.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ impl StructGenerator {
102102
quote! {
103103
#[automatically_derived]
104104
impl ::enum_map::Enum for #name {
105-
type Array<V> = [V; #length];
105+
type Array<__EnumMapInternalV> = [__EnumMapInternalV; #length];
106106

107107
#[inline]
108108
fn from_usize(value: ::enum_map::usize) -> Self {

enum-map/tests/test.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,3 +639,12 @@ fn usize_override() {
639639
B,
640640
}
641641
}
642+
643+
#[derive(Enum)]
644+
enum V {
645+
V,
646+
}
647+
#[derive(Enum)]
648+
struct StructureCanHoldV {
649+
v: V,
650+
}

0 commit comments

Comments
 (0)