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.
This commit is contained in:
Manlio Perillo 2022-12-08 14:34:43 +01:00 committed by Andrew Kelley
parent 21dafd7a54
commit 1d5368fa35

View File

@ -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);