Skip to content

Commit 50e93ab

Browse files
authored
1 parent e083f59 commit 50e93ab

File tree

5 files changed

+5
-16
lines changed

5 files changed

+5
-16
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ name: CI
22

33
on:
44
workflow_dispatch:
5-
schedule:
6-
- cron: '10 20 * * *'
75
pull_request:
86
paths:
97
- "**.zig"
@@ -27,12 +25,9 @@ jobs:
2725
fail-fast: false
2826
matrix:
2927
os: [ubuntu-latest, macos-latest]
30-
zig-version: [0.15.1]
3128
steps:
3229
- uses: actions/checkout@v4
3330
- uses: mlugg/setup-zig@v2
34-
with:
35-
version: ${{ matrix.zig-version }}
3631
- name: Start services
3732
uses: ikalnytskyi/action-setup-postgres@v7
3833
with:

assets/src/01-01.zig

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@ pub fn main() !void {
99
var file_buffer: [4096]u8 = undefined;
1010
var reader = file.reader(&file_buffer);
1111
var line_no: usize = 0;
12-
while (reader.interface.takeDelimiterExclusive('\n')) |line| {
12+
while (try reader.interface.takeDelimiter('\n')) |line| {
1313
line_no += 1;
1414
print("{d}--{s}\n", .{ line_no, line });
15-
} else |err| switch (err) {
16-
error.EndOfStream => {}, // Normal termination
17-
else => return err, // Propagate error
1815
}
1916

17+
try std.testing.expectEqual(13, line_no);
2018
print("Total lines: {d}\n", .{line_no});
2119
}

build.zig.zon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
.name = .zig_cookbook,
33
.fingerprint = 0xde9a8a438b394bd0,
44
.version = "0.1.0",
5-
.minimum_zig_version = "0.14.0",
5+
.minimum_zig_version = "0.15.2",
66
.paths = .{
77
"src",
88
"lib",

src/en-US/01-01-read-file-line-by-line.smd

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
.layout = "section.shtml",
66
---
77

8-
There is a [`Reader`] type in Zig, which provides various methods to read file, such as `readAll`, `readInt`. Here we will use `takeDelimiterExclusive` to split lines.
8+
There is a `Reader` type in Zig, which provides various methods to read file, such as `readAll`, `readInt`. Here we will use `takeDelimiter` to split lines.
99

1010
[]($code.siteAsset('src/01-01.zig').language('zig'))
11-
12-
[`reader`]: https://ziglang.org/documentation/0.14.0/std/#std.io.Reader

src/zh-CN/01-01-read-file-line-by-line.smd

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
.layout = "section.shtml",
66
---
77

8-
在 Zig 中逐行读取文件,可以使用标准库中的 [`Reader`] 类型。它提供了多种方法来读取文件内容,例如 `readAll`、`readInt` 等。这里我们将使用 `takeDelimiterExclusive` 方法来按行分割读取。
8+
在 Zig 中逐行读取文件,可以使用标准库中的 `Reader` 类型。它提供了多种方法来读取文件内容,例如 `readAll`、`readInt` 等。这里我们将使用 `takeDelimiter` 方法来按行分割读取。
99

1010
[]($code.siteAsset('src/01-01.zig').language('zig'))
11-
12-
[`reader`]: https://ziglang.org/documentation/0.14.0/std/#std.io.Reader

0 commit comments

Comments
 (0)