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.
This commit is contained in:
committed by
Andrew Kelley
parent
7f41e20802
commit
f19b5ecf4b
@@ -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`.
|
||||
|
||||
Reference in New Issue
Block a user