range: make sure the generic in an integer

This commit is contained in:
Eugene Rossokha
2025-03-24 14:39:58 +02:00
parent 1effc9e76f
commit 8ff23928fc
+6
View File
@@ -4,6 +4,12 @@ const std = @import("std");
/// Non-inclusive range type over `T`.
pub fn Range(comptime T: type) type {
switch (@typeInfo(T)) {
.int => {},
else => {
@compileError("Range(T) only support integer ranges");
},
}
return struct {
/// Range start.
start: T,