Function alignCast [src]

Align cast a pointer but return an error if it's the wrong alignment

Prototype

pub fn alignCast(comptime alignment: u29, ptr: anytype) AlignCastError!AlignCastResult(alignment, @TypeOf(ptr))

Parameters

alignment: u29

Possible Errors

UnalignedMemory

Source

pub fn alignCast(comptime alignment: u29, ptr: anytype) AlignCastError!AlignCastResult(alignment, @TypeOf(ptr)) { const addr = @intFromPtr(ptr); if (addr % alignment != 0) { return error.UnalignedMemory; } return @alignCast(ptr); }