Commit 3c046ab9d9

IOKG04 <iokg04@gmail.com>
2025-07-22 12:23:16
`[:x]T` coerces into `[*:x]T`
https://github.com/ziglang/zig/issues/9628
1 parent c41ac8f
Changed files (1)
doc/langref/test_coerce_slices_arrays_and_pointers.zig
@@ -67,4 +67,11 @@ test "*T to *[1]T" {
     try expect(z[0] == 1234);
 }
 
+// Sentinel-terminated slices can be coerced into sentinel-terminated pointers
+test "[:x]T to [*:x]T" {
+    const buf: [:0]const u8 = "hello";
+    const buf2: [*:0]const u8 = buf;
+    try expect(buf2[4] == 'o');
+}
+
 // test