Skip to content

IRaw ​

IRaw is the Interface version of *anyopaque

zig
pub const IRaw = struct {
    ptr: *anyopaque,
    vptr: *anyopaque,
};

Convert to IRaw via asraw(), and then convert to any Interface via IRaw.cast(). No type information is used here, so the user must ensure the correctness of the conversion.

cast ​

zig
pub fn cast(self: IRaw, comptime I: type) I

Function: Force conversion to an interface of type I

parameter:

  • self: source IRaw instance
  • I: target type

Returns: An I instance that directly copies self.ptr and self.vptr

cast is equivalent to the following code

zig
pub fn cast(self: IRaw, comptime I: type) I {
    return I{.ptr = self.ptr, .vptr = @ptrCast(@alignCast(self.vptr))};
}

Released under the MIT License