diff options
| author | r00ster <r00ster91@proton.me> | 2022-07-25 21:04:30 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-25 22:04:30 +0300 |
| commit | cff5d9c805aa3433cc2562c3cb29bd3201817214 (patch) | |
| tree | aa7bedeeb92523806f79887159d66b8b2934f375 /src | |
| parent | 2f34d06d01189ae6349e9c6341ba85ec50b92bb0 (diff) | |
| download | zig-cff5d9c805aa3433cc2562c3cb29bd3201817214.tar.gz zig-cff5d9c805aa3433cc2562c3cb29bd3201817214.zip | |
std.mem: add `first` method to `SplitIterator` and `SplitBackwardsIterator`
Diffstat (limited to 'src')
| -rw-r--r-- | src/Compilation.zig | 2 | ||||
| -rw-r--r-- | src/libc_installation.zig | 5 | ||||
| -rw-r--r-- | src/test.zig | 6 |
3 files changed, 5 insertions, 8 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig index 5204910193..347f1ea0f5 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -4392,7 +4392,7 @@ pub fn hasSharedLibraryExt(filename: []const u8) bool { } // Look for .so.X, .so.X.Y, .so.X.Y.Z var it = mem.split(u8, filename, "."); - _ = it.next().?; + _ = it.first(); var so_txt = it.next() orelse return false; while (!mem.eql(u8, so_txt, "so")) { so_txt = it.next() orelse return false; diff --git a/src/libc_installation.zig b/src/libc_installation.zig index 0b40580d7b..f9f6b37fba 100644 --- a/src/libc_installation.zig +++ b/src/libc_installation.zig @@ -64,10 +64,7 @@ pub const LibCInstallation = struct { while (it.next()) |line| { if (line.len == 0 or line[0] == '#') continue; var line_it = std.mem.split(u8, line, "="); - const name = line_it.next() orelse { - log.err("missing equal sign after field name\n", .{}); - return error.ParseError; - }; + const name = line_it.first(); const value = line_it.rest(); inline for (fields) |field, i| { if (std.mem.eql(u8, name, field.name)) { diff --git a/src/test.zig b/src/test.zig index 20a7d1673a..554248c2de 100644 --- a/src/test.zig +++ b/src/test.zig @@ -303,7 +303,7 @@ const TestManifest = struct { // Parse key=value(s) var kv_it = std.mem.split(u8, trimmed, "="); - const key = kv_it.next() orelse return error.MissingKeyForConfig; + const key = kv_it.first(); try manifest.config_map.putNoClobber(key, kv_it.next() orelse return error.MissingValuesForConfig); } @@ -697,7 +697,7 @@ pub const TestContext = struct { } // example: "file.zig:1:2: error: bad thing happened" var it = std.mem.split(u8, err_msg_line, ":"); - const src_path = it.next() orelse @panic("missing colon"); + const src_path = it.first(); const line_text = it.next() orelse @panic("missing line"); const col_text = it.next() orelse @panic("missing column"); const kind_text = it.next() orelse @panic("missing 'error'/'note'"); @@ -1698,7 +1698,7 @@ pub const TestContext = struct { var fib = std.io.fixedBufferStream(&buf); try msg.renderToWriter(.no_color, fib.writer(), "error", .Red, 0); var it = std.mem.split(u8, fib.getWritten(), "error: "); - _ = it.next(); + _ = it.first(); const rendered = it.rest(); break :blk rendered[0 .. rendered.len - 1]; // trim final newline }; |
