Use alignCast over intToPtr

This commit is contained in:
Richard Feldman 2022-07-02 15:22:29 -04:00
parent 284ff5de35
commit 077c37d9fb
No known key found for this signature in database
GPG Key ID: 7E4127D1E4241798

View File

@ -79,9 +79,7 @@ pub const RocList = extern struct {
}
pub fn elements(self: RocList, comptime T: type) ?[*]T {
// Is there a better way to make this cast happen?
// @ptrCast gives an error because this increases alignment.
return @intToPtr(?[*]T, @ptrToInt(self.bytes));
return @ptrCast(?[*]T, @alignCast(@alignOf(T), self.bytes));
}
pub fn isUnique(self: RocList) bool {