This is similar to a question I posed a while ago: Do comptime variables have "static" lifetime?
The example that @kristoff gave could be modified to suite your needs here because it shows up as part of a type definition.
fn foo() [] u32 {
const Internal = struct {
var a = [_] u32 {5, 6};
};
return &Internal.a;
}
fn bar() [] const u32 {
const Internal = struct {
const a = [_] u32 {5, 6};
};
return &Internal.a;
}
pub fn main() !void {
std.debug.print("\n{any}\n", .{ foo() });
std.debug.print("\n{any}\n", .{ bar() });
}