| ... | @@ -747,13 +747,7 @@ pub fn EnumArray(comptime E: type, comptime V: type) type { | ... | @@ -747,13 +747,7 @@ pub fn EnumArray(comptime E: type, comptime V: type) type { |
| 747 | return IndexedArray(EnumIndexer(E), V, mixin.EnumArrayExt); | 747 | return IndexedArray(EnumIndexer(E), V, mixin.EnumArrayExt); |
| 748 | } | 748 | } |
| 749 | | 749 | |
| 750 | /// Pass this function as the Ext parameter to Indexed* if you | 750 | fn NoExtension(comptime Self: type) type { |
| 751 | /// do not want to attach any extensions. This parameter was | | |
| 752 | /// originally an optional, but optional generic functions | | |
| 753 | /// seem to be broken at the moment. | | |
| 754 | /// TODO: Once #8169 is fixed, consider switching this param | | |
| 755 | /// back to an optional. | | |
| 756 | pub fn NoExtension(comptime Self: type) type { | | |
| 757 | _ = Self; | 751 | _ = Self; |
| 758 | return NoExt; | 752 | return NoExt; |
| 759 | } | 753 | } |
| ... | @@ -762,12 +756,12 @@ const NoExt = struct {}; | ... | @@ -762,12 +756,12 @@ const NoExt = struct {}; |
| 762 | /// A set type with an Indexer mapping from keys to indices. | 756 | /// A set type with an Indexer mapping from keys to indices. |
| 763 | /// Presence or absence is stored as a dense bitfield. This | 757 | /// Presence or absence is stored as a dense bitfield. This |
| 764 | /// type does no allocation and can be copied by value. | 758 | /// type does no allocation and can be copied by value. |
| 765 | pub fn IndexedSet(comptime I: type, comptime Ext: fn (type) type) type { | 759 | pub fn IndexedSet(comptime I: type, comptime Ext: ?fn (type) type) type { |
| 766 | comptime ensureIndexer(I); | 760 | comptime ensureIndexer(I); |
| 767 | return struct { | 761 | return struct { |
| 768 | const Self = @This(); | 762 | const Self = @This(); |
| 769 | | 763 | |
| 770 | pub usingnamespace Ext(Self); | 764 | pub usingnamespace (Ext orelse NoExtension)(Self); |
| 771 | | 765 | |
| 772 | /// The indexing rules for converting between keys and indices. | 766 | /// The indexing rules for converting between keys and indices. |
| 773 | pub const Indexer = I; | 767 | pub const Indexer = I; |
| ... | @@ -1007,12 +1001,12 @@ test "std.enums.EnumSet const iterator" { | ... | @@ -1007,12 +1001,12 @@ test "std.enums.EnumSet const iterator" { |
| 1007 | /// A map from keys to values, using an index lookup. Uses a | 1001 | /// A map from keys to values, using an index lookup. Uses a |
| 1008 | /// bitfield to track presence and a dense array of values. | 1002 | /// bitfield to track presence and a dense array of values. |
| 1009 | /// This type does no allocation and can be copied by value. | 1003 | /// This type does no allocation and can be copied by value. |
| 1010 | pub fn IndexedMap(comptime I: type, comptime V: type, comptime Ext: fn (type) type) type { | 1004 | pub fn IndexedMap(comptime I: type, comptime V: type, comptime Ext: ?fn (type) type) type { |
| 1011 | comptime ensureIndexer(I); | 1005 | comptime ensureIndexer(I); |
| 1012 | return struct { | 1006 | return struct { |
| 1013 | const Self = @This(); | 1007 | const Self = @This(); |
| 1014 | | 1008 | |
| 1015 | pub usingnamespace Ext(Self); | 1009 | pub usingnamespace (Ext orelse NoExtension)(Self); |
| 1016 | | 1010 | |
| 1017 | /// The index mapping for this map | 1011 | /// The index mapping for this map |
| 1018 | pub const Indexer = I; | 1012 | pub const Indexer = I; |
| ... | @@ -1167,12 +1161,12 @@ pub fn IndexedMap(comptime I: type, comptime V: type, comptime Ext: fn (type) ty | ... | @@ -1167,12 +1161,12 @@ pub fn IndexedMap(comptime I: type, comptime V: type, comptime Ext: fn (type) ty |
| 1167 | | 1161 | |
| 1168 | /// A dense array of values, using an indexed lookup. | 1162 | /// A dense array of values, using an indexed lookup. |
| 1169 | /// This type does no allocation and can be copied by value. | 1163 | /// This type does no allocation and can be copied by value. |
| 1170 | pub fn IndexedArray(comptime I: type, comptime V: type, comptime Ext: fn (type) type) type { | 1164 | pub fn IndexedArray(comptime I: type, comptime V: type, comptime Ext: ?fn (type) type) type { |
| 1171 | comptime ensureIndexer(I); | 1165 | comptime ensureIndexer(I); |
| 1172 | return struct { | 1166 | return struct { |
| 1173 | const Self = @This(); | 1167 | const Self = @This(); |
| 1174 | | 1168 | |
| 1175 | pub usingnamespace Ext(Self); | 1169 | pub usingnamespace (Ext orelse NoExtension)(Self); |
| 1176 | | 1170 | |
| 1177 | /// The index mapping for this map | 1171 | /// The index mapping for this map |
| 1178 | pub const Indexer = I; | 1172 | pub const Indexer = I; |