master
 1const expect = @import("std").testing.expect;
 2
 3test "inline for loop" {
 4    const nums = [_]i32{ 2, 4, 6 };
 5    var sum: usize = 0;
 6    inline for (nums) |i| {
 7        const T = switch (i) {
 8            2 => f32,
 9            4 => i8,
10            6 => bool,
11            else => unreachable,
12        };
13        sum += typeNameLength(T);
14    }
15    try expect(sum == 9);
16}
17
18fn typeNameLength(comptime T: type) usize {
19    return @typeName(T).len;
20}
21
22// test