Added a UnitParser to get Dimensions and Scales from a str

This commit is contained in:
adrien
2026-05-04 19:10:06 +02:00
parent 9b6cd4b377
commit 7844aacfce
3 changed files with 149 additions and 1 deletions
+2 -1
View File
@@ -59,7 +59,8 @@ pub const UnitScale = enum(isize) {
var buf: [16]u8 = undefined;
return switch (self) {
.none => "",
.P, .T, .G, .M, .k, .h, .da, .d, .c, .m, .u, .n, .p, .f, .min, .hour, .year, .inch, .ft, .yd, .mi, .oz, .lb, .st => @tagName(self),
.P, .T, .G, .M, .k, .h, .da, .d, .c, .m, .u, .n, .p, .f, .min, .year, .inch, .ft, .yd, .mi, .oz, .lb, .st => @tagName(self),
.hour => "h",
else => std.fmt.bufPrint(&buf, "[{d}]", .{@intFromEnum(self)}) catch "[]", // This cannot be inline because of non exhaustive enum, but that's ok, it is just str, not calculation
};
}