I have this code:
const offset = @ptrToInt(token.ptr) - @ptrToInt(text.ptr);
if (offset >= skip_prefix.len + "``".len) {
if (std.mem.eql(
u8,
skip_prefix,
@intToPtr([*]const u8, @ptrToInt(token.ptr) - (skip_prefix.len + "``".len))[0..skip_prefix.len],
)) continue :outer;
}
I have managed to convert to this point
const offset = @intFromPtr(token.ptr) - @intFromPtr(text.ptr);
if (offset >= skip_prefix.len + "``".len) {
const one: [*]const u8 = @as([*]const u8, @ptrFromInt(@intFromPtr(token.ptr) - (skip_prefix.len + "``".len))[0..skip_prefix.len]);
if (std.mem.eql(
u8,
skip_prefix,
one,
)) continue :outer;
}
but got error:
% zig run test-out.zig
test-out.zig:46:63: error: @ptrFromInt must have a known result type
const one: [*]const u8 = @as([*]const u8, @ptrFromInt(@intFromPtr(token.ptr) - (skip_prefix.len + "``".len))[0..skip_prefix.len]);
test-out.zig:46:63: note: use @as to provide explicit result type