This commit is contained in:
2026-01-19 05:43:29 +09:00
parent 40f41a4fd0
commit 0f6fddd794
36 changed files with 1724 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
const expect = @import("std").testing.expect;
// inline loops are unrolled, and allow some things to happen that only work at compile time.
// Here we use a for, but a while works similarly.
test "inline for" {
const types = [_]type{ i32, f32, u8, bool };
var sum: usize = 0;
inline for (types) |T| sum += @sizeOf(T);
try expect(sum == 10);
}
// Using these for performance reasons is inadvisable unless you've tested that explicitly unrolling is faster;
// the compiler tends to make better decisions here than you.