aboutsummaryrefslogtreecommitdiff
path: root/lib/std/array_list.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-09-02 04:51:42 -0400
committerGitHub <noreply@github.com>2021-09-02 04:51:42 -0400
commit594271f8dba0143280990ac2e01dd68a791c05b0 (patch)
tree33cfda1ae8fb44e36cc0b1e6dcdad76063f345d7 /lib/std/array_list.zig
parent81e2034d4ad935185344030e5ecedbd1388a65e9 (diff)
parent2264fca03e6ce9203baf52d70825ec3bc32f8262 (diff)
downloadzig-594271f8dba0143280990ac2e01dd68a791c05b0.tar.gz
zig-594271f8dba0143280990ac2e01dd68a791c05b0.zip
Merge pull request #9618 from ziglang/std-os-reorg
std.os reorganization; new `usingnamespace` semantics
Diffstat (limited to 'lib/std/array_list.zig')
-rw-r--r--lib/std/array_list.zig28
1 files changed, 15 insertions, 13 deletions
diff --git a/lib/std/array_list.zig b/lib/std/array_list.zig
index f6ee5cdad2..3a66b9bb36 100644
--- a/lib/std/array_list.zig
+++ b/lib/std/array_list.zig
@@ -236,21 +236,23 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type {
mem.copy(T, self.items[old_len..], items);
}
- pub usingnamespace if (T != u8) struct {} else struct {
- pub const Writer = std.io.Writer(*Self, error{OutOfMemory}, appendWrite);
+ 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.Writer(*Self, error{OutOfMemory}, appendWrite);
- /// Initializes a Writer which will append to the list.
- pub fn writer(self: *Self) Writer {
- return .{ .context = self };
- }
+ /// 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.Writer` API.
- fn appendWrite(self: *Self, m: []const u8) !usize {
- try self.appendSlice(m);
- return m.len;
- }
- };
+ /// 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.Writer` API.
+ fn appendWrite(self: *Self, m: []const u8) !usize {
+ try self.appendSlice(m);
+ return m.len;
+ }
/// Append a value to the list `n` times.
/// Allocates more memory as necessary.