fn requiresAllocator(T: type) bool T: type461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480fn requiresAllocator(T: type) bool {
_ = valid_types;
return switch (@typeInfo(T)) {
.pointer => true,
.array => |array| return array.len > 0 and requiresAllocator(array.child),
.@"struct" => |@"struct"| inline for (@"struct".field_types) |field_type| {
if (requiresAllocator(field_type)) {
break true;
}
} else false,
.@"union" => |@"union"| inline for (@"union".field_types) |field_type| {
if (requiresAllocator(field_type)) {
break true;
}
} else false,
.optional => |optional| requiresAllocator(optional.child),
.vector => |vector| return vector.len > 0 and requiresAllocator(vector.child),
else => false,
};
}