Returns the alignment of type T. Note that if T is a pointer type the result is different than the one returned by @alignOf(T). If T is a pointer type the alignment of the type it points to is returned.
pub fn alignment(comptime T: type) comptime_int
pub fn alignment(comptime T: type) comptime_int {
return switch (@typeInfo(T)) {
.optional => |info| switch (@typeInfo(info.child)) {
.pointer, .@"fn" => alignment(info.child),
else => @alignOf(T),
},
.pointer => |info| info.attrs.@"align" orelse @alignOf(info.child),
else => @alignOf(T),
};
}