Elem
Given a "memory span" type (array, slice, vector, or pointer to such), returns the "element type".
Source
Implementation
pub fn Elem(comptime T: type) type {
switch (@typeInfo(T)) {
.array => |info| return info.child,
.vector => |info| return info.child,
.pointer => |info| switch (info.size) {
.one => switch (@typeInfo(info.child)) {
.array => |array_info| return array_info.child,
.vector => |vector_info| return vector_info.child,
else => {},
},
.many, .c, .slice => return info.child,
},
.optional => |info| return Elem(info.child),
else => {},
}
@compileError("Expected pointer, slice, array or vector type, found '" ++ @typeName(T) ++ "'");
}