@@ -15,16 +15,16 @@ const testing = std.testing;
1515/// var slice = a.slice(); // a slice of the 64-byte array
1616/// var a_clone = a; // creates a copy - the structure doesn't use any internal pointers
1717/// ```
18- pub fn BoundedArray (comptime T : type , comptime capacity : usize ) type {
18+ pub fn BoundedArray (comptime T : type , comptime buffer_capacity : usize ) type {
1919 return struct {
2020 const Self = @This ();
21- buffer : [capacity ]T = undefined ,
21+ buffer : [buffer_capacity ]T = undefined ,
2222 len : usize = 0 ,
2323
2424 /// Set the actual length of the slice.
2525 /// Returns error.Overflow if it exceeds the length of the backing array.
2626 pub fn init (len : usize ) error {Overflow }! Self {
27- if (len > capacity ) return error .Overflow ;
27+ if (len > buffer_capacity ) return error .Overflow ;
2828 return Self { .len = len };
2929 }
3030
@@ -41,7 +41,7 @@ pub fn BoundedArray(comptime T: type, comptime capacity: usize) type {
4141 /// Adjust the slice's length to `len`.
4242 /// Does not initialize added items if any.
4343 pub fn resize (self : * Self , len : usize ) error {Overflow }! void {
44- if (len > capacity ) return error .Overflow ;
44+ if (len > buffer_capacity ) return error .Overflow ;
4545 self .len = len ;
4646 }
4747
@@ -69,7 +69,7 @@ pub fn BoundedArray(comptime T: type, comptime capacity: usize) type {
6969
7070 /// Check that the slice can hold at least `additional_count` items.
7171 pub fn ensureUnusedCapacity (self : Self , additional_count : usize ) error {Overflow }! void {
72- if (self .len + additional_count > capacity ) {
72+ if (self .len + additional_count > buffer_capacity ) {
7373 return error .Overflow ;
7474 }
7575 }
@@ -83,7 +83,7 @@ pub fn BoundedArray(comptime T: type, comptime capacity: usize) type {
8383 /// Increase length by 1, returning pointer to the new item.
8484 /// Asserts that there is space for the new item.
8585 pub fn addOneAssumeCapacity (self : * Self ) * T {
86- assert (self .len < capacity );
86+ assert (self .len < buffer_capacity );
8787 self .len += 1 ;
8888 return & self .slice ()[self .len - 1 ];
8989 }
@@ -236,7 +236,7 @@ pub fn BoundedArray(comptime T: type, comptime capacity: usize) type {
236236 pub fn appendNTimesAssumeCapacity (self : * Self , value : T , n : usize ) void {
237237 const old_len = self .len ;
238238 self .len += n ;
239- assert (self .len <= capacity );
239+ assert (self .len <= buffer_capacity );
240240 mem .set (T , self .slice ()[old_len .. self .len ], value );
241241 }
242242
0 commit comments