diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2025-08-07 23:09:40 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2025-08-28 18:30:57 -0700 |
| commit | 57dbc9e74a3f19802e4592f35061f1524c218a8f (patch) | |
| tree | 02adaff978e089c10fdccc46564ad3393a1a0391 /lib/std/array_list.zig | |
| parent | 5cb8cdef1026f0b5d1c18cc5d5e6525cddf65d67 (diff) | |
| download | zig-57dbc9e74a3f19802e4592f35061f1524c218a8f.tar.gz zig-57dbc9e74a3f19802e4592f35061f1524c218a8f.zip | |
std.Io: delete GenericWriter
Diffstat (limited to 'lib/std/array_list.zig')
| -rw-r--r-- | lib/std/array_list.zig | 75 |
1 files changed, 0 insertions, 75 deletions
diff --git a/lib/std/array_list.zig b/lib/std/array_list.zig index 486deffafd..1277b477ca 100644 --- a/lib/std/array_list.zig +++ b/lib/std/array_list.zig @@ -336,39 +336,6 @@ pub fn AlignedManaged(comptime T: type, comptime alignment: ?mem.Alignment) type try unmanaged.print(gpa, fmt, args); } - pub const Writer = if (T != u8) void else std.io.GenericWriter(*Self, Allocator.Error, appendWrite); - - /// Initializes a Writer which will append to the list. - pub fn writer(self: *Self) Writer { - return .{ .context = self }; - } - - /// Same as `append` except it returns the number of bytes written, which is always the same - /// as `m.len`. The purpose of this function existing is to match `std.io.GenericWriter` API. - /// Invalidates element pointers if additional memory is needed. - fn appendWrite(self: *Self, m: []const u8) Allocator.Error!usize { - try self.appendSlice(m); - return m.len; - } - - pub const FixedWriter = std.io.GenericWriter(*Self, Allocator.Error, appendWriteFixed); - - /// Initializes a Writer which will append to the list but will return - /// `error.OutOfMemory` rather than increasing capacity. - pub fn fixedWriter(self: *Self) FixedWriter { - return .{ .context = self }; - } - - /// The purpose of this function existing is to match `std.io.GenericWriter` API. - fn appendWriteFixed(self: *Self, m: []const u8) error{OutOfMemory}!usize { - const available_capacity = self.capacity - self.items.len; - if (m.len > available_capacity) - return error.OutOfMemory; - - self.appendSliceAssumeCapacity(m); - return m.len; - } - /// Append a value to the list `n` times. /// Allocates more memory as necessary. /// Invalidates element pointers if additional memory is needed. @@ -1083,48 +1050,6 @@ pub fn Aligned(comptime T: type, comptime alignment: ?mem.Alignment) type { self.items.len += w.end; } - /// Deprecated in favor of `print` or `std.io.Writer.Allocating`. - pub const WriterContext = struct { - self: *Self, - allocator: Allocator, - }; - - /// Deprecated in favor of `print` or `std.io.Writer.Allocating`. - pub const Writer = if (T != u8) - @compileError("The Writer interface is only defined for ArrayList(u8) " ++ - "but the given type is ArrayList(" ++ @typeName(T) ++ ")") - else - std.io.GenericWriter(WriterContext, Allocator.Error, appendWrite); - - /// Deprecated in favor of `print` or `std.io.Writer.Allocating`. - pub fn writer(self: *Self, gpa: Allocator) Writer { - return .{ .context = .{ .self = self, .allocator = gpa } }; - } - - /// Deprecated in favor of `print` or `std.io.Writer.Allocating`. - fn appendWrite(context: WriterContext, m: []const u8) Allocator.Error!usize { - try context.self.appendSlice(context.allocator, m); - return m.len; - } - - /// Deprecated in favor of `print` or `std.io.Writer.Allocating`. - pub const FixedWriter = std.io.GenericWriter(*Self, Allocator.Error, appendWriteFixed); - - /// Deprecated in favor of `print` or `std.io.Writer.Allocating`. - pub fn fixedWriter(self: *Self) FixedWriter { - return .{ .context = self }; - } - - /// Deprecated in favor of `print` or `std.io.Writer.Allocating`. - fn appendWriteFixed(self: *Self, m: []const u8) error{OutOfMemory}!usize { - const available_capacity = self.capacity - self.items.len; - if (m.len > available_capacity) - return error.OutOfMemory; - - self.appendSliceAssumeCapacity(m); - return m.len; - } - /// Append a value to the list `n` times. /// Allocates more memory as necessary. /// Invalidates element pointers if additional memory is needed. |
