Function alignCast [src]
Align cast a pointer but return an error if it's the wrong alignment
Prototype
pub fn alignCast(comptime alignment: Alignment, ptr: anytype) AlignCastError!AlignCastResult(alignment, @TypeOf(ptr))
Parameters
alignment: Alignment
Possible Errors
Source
pub fn alignCast(comptime alignment: Alignment, ptr: anytype) AlignCastError!AlignCastResult(alignment, @TypeOf(ptr)) {
if (alignment.check(@intFromPtr(ptr))) return @alignCast(ptr);
return error.UnalignedMemory;
}