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

Commit

Permalink
Allow storing V with #[derive(Enum)]
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
KamilaBorowska committed Sep 7, 2023
1 parent c39739e commit 7e78192
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion enum-map-derive/src/derive_enum.rs
Expand Up @@ -37,7 +37,7 @@ impl EnumGenerator {
quote! {
#[automatically_derived]
impl ::enum_map::Enum for #name {
type Array<V> = [V; #length];
type Array<__EnumMapInternalV> = [__EnumMapInternalV; #length];

#[inline]
fn from_usize(value: ::enum_map::usize) -> Self {
Expand Down
2 changes: 1 addition & 1 deletion enum-map-derive/src/derive_struct.rs
Expand Up @@ -102,7 +102,7 @@ impl StructGenerator {
quote! {
#[automatically_derived]
impl ::enum_map::Enum for #name {
type Array<V> = [V; #length];
type Array<__EnumMapInternalV> = [__EnumMapInternalV; #length];

#[inline]
fn from_usize(value: ::enum_map::usize) -> Self {
Expand Down
9 changes: 9 additions & 0 deletions enum-map/tests/test.rs
Expand Up @@ -639,3 +639,12 @@ fn usize_override() {
B,
}
}

#[derive(Enum)]
enum V {
V,
}
#[derive(Enum)]
struct StructureCanHoldV {
v: V,
}

0 comments on commit 7e78192

Please sign in to comment.