authorgravatar for iokg04@gmail.comIOKG04 <iokg04@gmail.com> 2025-07-22 12:23:16+02:00
committergravatar for iokg04@gmail.comIOKG04 <iokg04@gmail.com> 2025-07-22 12:30:19+02:00
log3c046ab9d94c96632bdfd21ad20bea0613bfc1e2
treeb698f2895f89b8be64d7ac40db641dffca7862b9
parentc41ac8f19ec96ed854d9ac31a2015006ba3e4657

`[:x]T` coerces into `[*:x]T`

https://github.com/ziglang/zig/issues/9628

1 files changed, 7 insertions(+), 0 deletions(-)

doc/langref/test_coerce_slices_arrays_and_pointers.zig+7
......@@ -67,4 +67,11 @@ test "*T to *[1]T" {
6767 try expect(z[0] == 1234);
6868}
6969
70// Sentinel-terminated slices can be coerced into sentinel-terminated pointers
71test "[:x]T to [*:x]T" {
72 const buf: [:0]const u8 = "hello";
73 const buf2: [*:0]const u8 = buf;
74 try expect(buf2[4] == 'o');
75}
76
7077// test