mirror of
https://codeberg.org/ziglang/zig
synced 2026-11-18 07:05:05 +00:00
The unmanaged variant does not rely on `std.ArrayList`, because a slice can perform the same function here while saving a `usize`. The managed implementation is marked *deprecated*. The `*WithState*` functions have been moved into a separate namespace, `std.BitStack.buffer`. Upgrade guide: ```zig var stack = try BitStack.init(allocator); // -> var stack: BitStackUnmanaged = .empty; stack.deinit(); // -> stack.deinit(allocator); try stack.push(bit); // -> try stack.push(allocator, bit); _ = stack.pop(); // -> _ = stack.pop().?; _ = stack.peek(); // -> _ = stack.peek().?; try stack.ensureTotalCapacity(size); // -> try stack.ensureTotalCapacity(allocator, size); BitStack.pushWithStateAssumeCapacity(buf, &bit_len, bit); // -> BitStack.buffer.pushAssumeCapacity(buf, &bit_len, bit); _ = BitStack.popWithState(buf, &bit_len); // -> _ = BitStack.buffer.pop(buf, &bit_len).?; _ = BitStack.peekWithState(buf, bit_len); // -> _ = BitStack.buffer.peek(buf, bit_len).?; ``` Reviewed-on: https://codeberg.org/ziglang/zig/pulls/35660 Reviewed-by: Ryan Liptak <squeek502@noreply.codeberg.org>
243 lines
11 KiB
243 lines
11 KiB