Been suggested many times and rejected each time.
- Proposal: C-style for loop · Issue #8292 · ziglang/zig · GitHub
- a place to put variables in only while loop scope · Issue #5070 · ziglang/zig · GitHub
- Introduce expression-scoped variables · Issue #8019 · ziglang/zig · GitHub
Potentially relevant:
Adding a new feature just to save a few lines of code isn’t really what Zig is interested in in my experience. Note also that for loops that work on ranges (e.g. for (0..end_index) |i| {
) only got added as a side-effect of a different change with other use cases in mind: Proposal: Multi-object `for` loops · Issue #7257 · ziglang/zig · GitHub