@@ -792,7 +792,7 @@ pub fn EnumMap(comptime E: type, comptime V: type) type {
792
792
793
793
pub fn next (self : * Iterator ) ? Entry {
794
794
return if (self .inner .next ()) | index |
795
- Entry {
795
+ . {
796
796
.key = Indexer .keyForIndex (index ),
797
797
.value = & self .values [index ],
798
798
}
@@ -816,6 +816,19 @@ test EnumMap {
816
816
try testing .expectEqual (0x80 , some .get (.blue ));
817
817
}
818
818
819
+ test "EnumMap iterator for one field" {
820
+ const Enum0 = std .meta .FieldEnum (struct { x : u32 });
821
+ const Enum1 = enum { x };
822
+
823
+ var a = std .EnumMap (Enum0 , u32 ).initFull (123 );
824
+ var it0 = a .iterator ();
825
+ try testing .expectEqual (it0 .next ().? .key , Enum0 .x );
826
+
827
+ var b = std .EnumMap (Enum1 , u32 ).initFull (123 );
828
+ var it1 = b .iterator ();
829
+ try testing .expectEqual (it1 .next ().? .key , Enum1 .x );
830
+ }
831
+
819
832
/// A multiset of enum elements up to a count of usize. Backed
820
833
/// by an EnumArray. This type does no dynamic allocation and can
821
834
/// be copied by value.
@@ -1292,7 +1305,7 @@ pub fn EnumArray(comptime E: type, comptime V: type) type {
1292
1305
key : Key ,
1293
1306
1294
1307
/// A pointer to the value in the array associated
1295
- /// with this key. Modifications through this
1308
+ /// with this key. Modifications through this
1296
1309
/// pointer will modify the underlying data.
1297
1310
value : * Value ,
1298
1311
};
0 commit comments