diff options
| author | Jimmi Holst Christensen <jhc@dismail.de> | 2022-01-12 18:45:36 +0100 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-01-16 01:37:37 -0500 |
| commit | f19b5ecf4b99652cd385cfdfedfa826260174871 (patch) | |
| tree | 653552e92dcce3b36648003a4fb9fa9bcf74dfc9 /lib/std/bounded_array.zig | |
| parent | 7f41e20802fd8f9eb19c0218f1e2000e2751592a (diff) | |
| download | zig-f19b5ecf4b99652cd385cfdfedfa826260174871.tar.gz zig-f19b5ecf4b99652cd385cfdfedfa826260174871.zip | |
Slice function of BoundedArray now returns slice based on self pointer
If self pointer is const, the slice is const. Otherwise the slice is
mutable.
Diffstat (limited to 'lib/std/bounded_array.zig')
| -rw-r--r-- | lib/std/bounded_array.zig | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/std/bounded_array.zig b/lib/std/bounded_array.zig index a7810697fc..519b7aff39 100644 --- a/lib/std/bounded_array.zig +++ b/lib/std/bounded_array.zig @@ -28,14 +28,14 @@ pub fn BoundedArray(comptime T: type, comptime capacity: usize) type { return Self{ .len = len }; } - /// View the internal array as a mutable slice whose size was previously set. - pub fn slice(self: *Self) []T { + /// View the internal array as a slice whose size was previously set. + pub fn slice(self: anytype) mem.Span(@TypeOf(&self.buffer)) { return self.buffer[0..self.len]; } /// View the internal array as a constant slice whose size was previously set. pub fn constSlice(self: *const Self) []const T { - return self.buffer[0..self.len]; + return self.slice(); } /// Adjust the slice's length to `len`. |
