authorgravatar for manlio.perillo@gmail.comManlio Perillo <manlio.perillo@gmail.com> 2022-12-08 14:34:43+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-12-13 14:59:46-05:00
log1d5368fa35740f64d81f755588edc5c6698036ec
tree504aa90c5fa89a66cf677ad9cb8bdcdb061b5ddc
parent21dafd7a54f1b3233e0e73439daee82aa08d4900

langref: fix the slice_bounds.zig doctest

In the slice_bounds.zig doctest, the code "const slice = array[2..4]" is incorrect, since the actual type is a pointer to an array, instead of a slice. Use a runtime know value to slice the array.

1 files changed, 2 insertions(+), 1 deletions(-)

doc/langref.html.in+2-1
...@@ -2691,7 +2691,8 @@ const expect = @import("std").testing.expect;...@@ -2691,7 +2691,8 @@ const expect = @import("std").testing.expect;
26912691
2692test "pointer slicing" {2692test "pointer slicing" {
2693 var array = [_]u8{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };2693 var array = [_]u8{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
2694 const slice = array[2..4];2694 var start: usize = 2;
2695 const slice = array[start..4];
2695 try expect(slice.len == 2);2696 try expect(slice.len == 2);
26962697
2697 try expect(array[3] == 4);2698 try expect(array[3] == 4);