Skip to content

Instantly share code, notes, and snippets.

const std = @import("std");
// Returns an instance of Interface wrapped around the implementation
// at ptr
pub fn as(comptime Interface: type, ptr: anytype) Interface {
return .{
.ptr = @ptrCast(@alignCast(ptr)),
.vtable = vtable(Interface.VTable, @TypeOf(ptr.*)),
};
}