Conversation
There was a problem hiding this comment.
Pull Request Overview
Bump project to Zig 0.15.2 and update examples/docs accordingly
- Raise minimum Zig version to 0.15.2
- Update sample code to use Reader.takeDelimiter and adjust flow; add a line-count assertion
- Revise docs (en-US, zh-CN) to reflect API change; CI no longer pins a Zig version
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| build.zig.zon | Set .minimum_zig_version to 0.15.2 to align with the new Zig toolchain. |
| assets/src/01-01.zig | Switch to takeDelimiter, simplify error propagation with try, and add a hard-coded expectEqual on line count. |
| src/en-US/01-01-read-file-line-by-line.smd | Update doc text to refer to takeDelimiter and remove the Reader reference link. |
| src/zh-CN/01-01-read-file-line-by-line.smd | Chinese doc mirrors the en-US changes: takeDelimiter reference and Reader link removal. |
| .github/workflows/ci.yml | Remove scheduled runs and unpin Zig version in setup-zig step. |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| else => return err, // Propagate error | ||
| } | ||
|
|
||
| try std.testing.expectEqual(13, line_no); |
There was a problem hiding this comment.
Hard-coding the expected line count (13) couples the sample to a specific file state and introduces a magic number in main(). Consider removing this assertion, or guard it so it only runs in tests, e.g., if (@import(\"builtin\").is_test) { try std.testing.expectEqual(13, line_no); }, or move this check into a dedicated test.
| try std.testing.expectEqual(13, line_no); | |
| if (@import("builtin").is_test) { | |
| try std.testing.expectEqual(13, line_no); | |
| } |
| zig-version: [0.15.1] | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: mlugg/setup-zig@v2 |
There was a problem hiding this comment.
CI no longer pins a Zig version, which can cause drift from .minimum_zig_version = \"0.15.2\" and lead to flaky builds when new Zig releases drop. Please pin the action to the required version, e.g., with: { version: '0.15.2' }, to keep CI reproducible and aligned with build.zig.zon.
| - uses: mlugg/setup-zig@v2 | |
| - uses: mlugg/setup-zig@v2 | |
| with: | |
| version: '0.15.2' |
| 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. | ||
|
|
||
| []($code.siteAsset('src/01-01.zig').language('zig')) |
There was a problem hiding this comment.
The inline Reader reference previously linked to the std docs; removing the link reduces discoverability. Consider restoring an updated reference for Zig 0.15.2, e.g., add a footnote: [Reader]: https://ziglang.org/documentation/0.15.2/std/#std.io.Reader.
| 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. | |
| []($code.siteAsset('src/01-01.zig').language('zig')) | |
| 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. | |
| []($code.siteAsset('src/01-01.zig').language('zig')) | |
| [`Reader`]: https://ziglang.org/documentation/0.15.2/std/#std.io.Reader |
| 在 Zig 中逐行读取文件,可以使用标准库中的 [`Reader`] 类型。它提供了多种方法来读取文件内容,例如 `readAll`、`readInt` 等。这里我们将使用 `takeDelimiterExclusive` 方法来按行分割读取。 | ||
| 在 Zig 中逐行读取文件,可以使用标准库中的 `Reader` 类型。它提供了多种方法来读取文件内容,例如 `readAll`、`readInt` 等。这里我们将使用 `takeDelimiter` 方法来按行分割读取。 | ||
|
|
||
| []($code.siteAsset('src/01-01.zig').language('zig')) |
There was a problem hiding this comment.
移除了 Reader 的文档链接会降低可查性。建议恢复并更新到 0.15.2 的链接,例如在文末添加脚注:[Reader]: https://ziglang.org/documentation/0.15.2/std/#std.io.Reader。
| []($code.siteAsset('src/01-01.zig').language('zig')) | |
| []($code.siteAsset('src/01-01.zig').language('zig')) | |
| [`Reader`]: https://ziglang.org/documentation/0.15.2/std/#std.io.Reader |
See ziglang/zig@bf58b4e#diff-54e633d204fe6689d53290ff4f09f03a6dd1ff12d3022ab92666f5d943e99453R732-R738