std.meta.Elem: support all optional types

This commit is contained in:
Isaac Freund
2021-05-11 22:21:22 +02:00
parent ace5714551
commit c036957521

View File

@@ -175,13 +175,7 @@ pub fn Elem(comptime T: type) type {
},
.Many, .C, .Slice => return info.child,
},
.Optional => |info| switch (@typeInfo(info.child)) {
.Pointer => |ptr_info| switch (ptr_info.size) {
.Many => return ptr_info.child,
else => {},
},
else => {},
},
.Optional => |info| return Elem(info.child),
else => {},
}
@compileError("Expected pointer, slice, array or vector type, found '" ++ @typeName(T) ++ "'");