master
1const Threshold = struct {
2 minimum: f32 = 0.25,
3 maximum: f32 = 0.75,
4
5 const Category = enum { low, medium, high };
6
7 fn categorize(t: Threshold, value: f32) Category {
8 assert(t.maximum >= t.minimum);
9 if (value < t.minimum) return .low;
10 if (value > t.maximum) return .high;
11 return .medium;
12 }
13};
14
15pub fn main() !void {
16 var threshold: Threshold = .{
17 .maximum = 0.20,
18 };
19 const category = threshold.categorize(0.90);
20 try std.fs.File.stdout().writeAll(@tagName(category));
21}
22
23const std = @import("std");
24const assert = std.debug.assert;
25
26// exe=fail