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_list.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_list.zig')
| -rw-r--r-- | lib/std/array_list.zig | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/std/array_list.zig b/lib/std/array_list.zig index 2510973692..24098a01f6 100644 --- a/lib/std/array_list.zig +++ b/lib/std/array_list.zig @@ -618,6 +618,8 @@ pub fn ArrayListUnmanaged(comptime T: type) type { /// Functions that potentially allocate memory accept an `Allocator` parameter. /// Initialize directly or with `initCapacity`, and deinitialize with `deinit` /// or use `toOwnedSlice`. +/// +/// Default initialization of this struct is deprecated; use `.empty` instead. pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) type { if (alignment) |a| { if (a == @alignOf(T)) { @@ -638,6 +640,12 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ /// additional memory. capacity: usize = 0, + /// An ArrayList containing no elements. + pub const empty: Self = .{ + .items = &.{}, + .capacity = 0, + }; + pub const Slice = if (alignment) |a| ([]align(a) T) else []T; pub fn SentinelSlice(comptime s: T) type { |
