File tree 1 file changed +19
-1
lines changed
1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -878,7 +878,7 @@ pub fn IndexedSet(comptime I: type, comptime Ext: fn (type) type) type {
878
878
/// index order. Modifications to the set during iteration
879
879
/// may or may not be observed by the iterator, but will
880
880
/// not invalidate it.
881
- pub fn iterator (self : * Self ) Iterator {
881
+ pub fn iterator (self : * const Self ) Iterator {
882
882
return .{ .inner = self .bits .iterator (.{}) };
883
883
}
884
884
@@ -970,6 +970,24 @@ test "pure EnumSet fns" {
970
970
try testing .expect (full .differenceWith (black ).eql (red ));
971
971
}
972
972
973
+ test "std.enums.EnumSet const iterator" {
974
+ const Direction = enum { up , down , left , right };
975
+ const diag_move = init : {
976
+ var move = EnumSet (Direction ).initEmpty ();
977
+ move .insert (.right );
978
+ move .insert (.up );
979
+ break :init move ;
980
+ };
981
+
982
+ var result = EnumSet (Direction ).initEmpty ();
983
+ var it = diag_move .iterator ();
984
+ while (it .next ()) | dir | {
985
+ result .insert (dir );
986
+ }
987
+
988
+ try testing .expect (result .eql (diag_move ));
989
+ }
990
+
973
991
/// A map from keys to values, using an index lookup. Uses a
974
992
/// bitfield to track presence and a dense array of values.
975
993
/// This type does no allocation and can be copied by value.
You can’t perform that action at this time.
0 commit comments