Uh oh!
There was an error while loading. Please reload this page.
Move stdlib imports to struct scope in hello_world examples - #362
Conversation
📝 WalkthroughWalkthroughThe hello-world examples now receive ChangesHello-world I/O flow
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@course/code/16/hello_world.zig`:
- Around line 3-6: Add independent Zig tests for the One, Two, and Three regions
in both course/code/16/hello_world.zig (lines 3-6) and
course/code/release/hello_world.zig (lines 3-6), producing one test per region
per file. Ensure the tests are discoverable by zig test and exercise each
corresponding entry point independently.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: a1687247-a38e-48e9-974a-1874f4c3cfe7
📒 Files selected for processing (3)
course/code/16/hello_world.zigcourse/code/release/hello_world.zigcourse/hello-world.md
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Summary
Refactor the hello_world examples to move stdlib imports from file-level to struct-level scope. Each struct now independently imports std, eliminating ambiguous reference errors and making each code snippet self-contained for copy-pasting into user projects.
Changes
Code changes (16/hello_world.zig and release/hello_world.zig):
const std = @import("std")into each struct (One, Two, Three)@import("std").process.Inittype referenceTwoandThreefunction signatures to acceptinit: std.process.Initdirectly, extractingioinside each functionTwoexample to use unbuffered output (&.{}) for clarityflush()calls from the unbuffered exampleDocumentation updates (hello-world.md):
init: std.process.Initparameter and its role&.{}means unbuffered (direct) outputflush()when using buffered I/OWhy
Each code snippet in the course is intended to be copyable directly into user projects. Moving imports to struct scope allows independent code samples without file-level import conflicts, and makes the relationship between initialization and I/O operations clearer for learners.
Summary by CodeRabbit