pub inline fn sentinel(comptime T: type) ?Elem(T) T: type107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123pub inline fn sentinel(comptime T: type) ?Elem(T) {
switch (@typeInfo(T)) {
.array => |info| return info.sentinel(),
.pointer => |info| {
switch (info.size) {
.many, .slice => return info.sentinel(),
.one => switch (@typeInfo(info.child)) {
.array => |array_info| return array_info.sentinel(),
else => {},
},
else => {},
}
},
else => {},
}
@compileError("type '" ++ @typeName(T) ++ "' cannot possibly have a sentinel");
}