Skip to content

Commit 3c046ab

Browse files
committed
[:x]T coerces into [*:x]T
#9628
1 parent c41ac8f commit 3c046ab

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

doc/langref/test_coerce_slices_arrays_and_pointers.zig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
71+
test "[: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

0 commit comments

Comments
 (0)