| 1 |
const std = @import("std"); |
| 2 |
|
| 3 |
const Point = struct { |
| 4 |
x: i32, |
| 5 |
y: i32, |
| 6 |
}; |
| 7 |
|
| 8 |
const Color = enum { |
| 9 |
red, |
| 10 |
green, |
| 11 |
}; |
| 12 |
|
| 13 |
const Value = union(enum) { |
| 14 |
int: i32, |
| 15 |
float: f64, |
| 16 |
}; |
| 17 |
|
| 18 |
fn classify(x: u32) u32 { |
| 19 |
const result = switch (x) { |
| 20 |
0 => 1, |
| 21 |
1, 2 => 2, |
| 22 |
else => 0, |
| 23 |
}; |
| 24 |
var i: usize = 0; |
| 25 |
while (i < 10) : (i += 1) { |
| 26 |
if (i > 5) { |
| 27 |
process(i); |
| 28 |
} else { |
| 29 |
other(i); |
| 30 |
} |
| 31 |
} |
| 32 |
const data = [_]u32{ |
| 33 |
1, |
| 34 |
2, |
| 35 |
}; |
| 36 |
const point = .{ |
| 37 |
.x = 1, |
| 38 |
.y = 2, |
| 39 |
}; |
| 40 |
return result; |
| 41 |
} |