79476450

Date: 2025-02-28 18:59:56
Score: 2
Natty:
Report link

I've figure out that you can achieve that by slicing a slice

const std = @import("std");

fn runtimeNumber() u16 {
    return 32;
}

fn func(b: [4]u8) void {
    std.debug.print("{any}", .{b});
}

pub fn main() void {
    var buf: [8096]u8 = undefined;

    const n = runtimeNumber();

    func(buf[n..][0..4].*);
}

https://ziglang.org/documentation/0.13.0/#Slices

Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: sloweax