From 1d5368fa35740f64d81f755588edc5c6698036ec Mon Sep 17 00:00:00 2001 From: Manlio Perillo Date: Thu, 8 Dec 2022 14:34:43 +0100 Subject: [PATCH] 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. --- doc/langref.html.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/langref.html.in b/doc/langref.html.in index 1625e7f800..868de8f1aa 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -2691,7 +2691,8 @@ const expect = @import("std").testing.expect; test "pointer slicing" { var array = [_]u8{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; - const slice = array[2..4]; + var start: usize = 2; + const slice = array[start..4]; try expect(slice.len == 2); try expect(array[3] == 4);