| ... | ... | @@ -227,6 +227,11 @@ pub fn ptrCast(comptime T: type, ptr: *anyopaque) *T { |
| 227 | 227 | return @ptrCast(*T, @alignCast(@alignOf(T), ptr)); |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | pub fn ptrCastConst(comptime T: type, ptr: *const anyopaque) *const T { |
| 231 | if (@alignOf(T) == 0) @compileError(@typeName(T)); |
| 232 | return @ptrCast(*const T, @alignCast(@alignOf(T), ptr)); |
| 233 | } |
| 234 | |
| 230 | 235 | pub fn sortBy(comptime T: type, items: []T, comptime field: std.meta.FieldEnum(T)) void { |
| 231 | 236 | std.sort.sort(T, items, {}, struct { |
| 232 | 237 | fn f(_: void, lhs: T, rhs: T) bool { |