diff options
| author | mlugg <mlugg@mlugg.co.uk> | 2024-08-31 02:50:11 +0100 |
|---|---|---|
| committer | mlugg <mlugg@mlugg.co.uk> | 2024-09-01 17:34:07 +0100 |
| commit | 0b9fccf508dc85fa522947d1cf6ff84f78f2dcb4 (patch) | |
| tree | 7371629835c5ee935b33515395f7ad7fbd64c897 /lib/std/array_hash_map.zig | |
| parent | 6e3e23a941c6c82550c41771a223afeec4accd47 (diff) | |
| download | zig-0b9fccf508dc85fa522947d1cf6ff84f78f2dcb4.tar.gz zig-0b9fccf508dc85fa522947d1cf6ff84f78f2dcb4.zip | |
std: deprecate some incorrect default initializations
In favour of newly-added decls, which can be used via decl literals.
Diffstat (limited to 'lib/std/array_hash_map.zig')
| -rw-r--r-- | lib/std/array_hash_map.zig | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/std/array_hash_map.zig b/lib/std/array_hash_map.zig index eb31d1cae3..1b96be472a 100644 --- a/lib/std/array_hash_map.zig +++ b/lib/std/array_hash_map.zig @@ -510,6 +510,8 @@ pub fn ArrayHashMap( /// `store_hash` is `false` and the number of entries in the map is less than 9, /// the overhead cost of using `ArrayHashMapUnmanaged` rather than `std.ArrayList` is /// only a single pointer-sized integer. +/// +/// Default initialization of this struct is deprecated; use `.empty` instead. pub fn ArrayHashMapUnmanaged( comptime K: type, comptime V: type, @@ -538,6 +540,12 @@ pub fn ArrayHashMapUnmanaged( /// Used to detect memory safety violations. pointer_stability: std.debug.SafetyLock = .{}, + /// A map containing no keys or values. + pub const empty: Self = .{ + .entries = .{}, + .index_header = null, + }; + /// Modifying the key is allowed only if it does not change the hash. /// Modifying the value is allowed. /// Entry pointers become invalid whenever this ArrayHashMap is modified, |
