mirror of
https://github.com/ziglang/zig.git
synced 2026-02-21 16:54:52 +00:00
std.array_list: tiny refactor for pleasure
This commit is contained in:
parent
943dac3e85
commit
b9355edfb1
@ -267,8 +267,7 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type {
|
|||||||
/// Never invalidates element pointers.
|
/// Never invalidates element pointers.
|
||||||
/// Asserts that the list can hold one additional item.
|
/// Asserts that the list can hold one additional item.
|
||||||
pub fn appendAssumeCapacity(self: *Self, item: T) void {
|
pub fn appendAssumeCapacity(self: *Self, item: T) void {
|
||||||
const new_item_ptr = self.addOneAssumeCapacity();
|
self.addOneAssumeCapacity().* = item;
|
||||||
new_item_ptr.* = item;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Remove the element at index `i`, shift elements after index
|
/// Remove the element at index `i`, shift elements after index
|
||||||
@ -879,8 +878,7 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ
|
|||||||
/// Never invalidates element pointers.
|
/// Never invalidates element pointers.
|
||||||
/// Asserts that the list can hold one additional item.
|
/// Asserts that the list can hold one additional item.
|
||||||
pub fn appendAssumeCapacity(self: *Self, item: T) void {
|
pub fn appendAssumeCapacity(self: *Self, item: T) void {
|
||||||
const new_item_ptr = self.addOneAssumeCapacity();
|
self.addOneAssumeCapacity().* = item;
|
||||||
new_item_ptr.* = item;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Remove the element at index `i` from the list and return its value.
|
/// Remove the element at index `i` from the list and return its value.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user