Improve documentation for string slices.

Closes #7454.
This commit is contained in:
Josh Holland 2020-12-15 18:41:50 +00:00 committed by Veikka Tuominen
parent e16997a66c
commit e93cb22541

View File

@ -2328,10 +2328,10 @@ const mem = std.mem;
const fmt = std.fmt; const fmt = std.fmt;
test "using slices for strings" { test "using slices for strings" {
// Zig has no concept of strings. String literals are const pointers to // Zig has no concept of strings. String literals are const pointers
// arrays of u8, and by convention parameters that are "strings" are // to null-terminated arrays of u8, and by convention parameters
// expected to be UTF-8 encoded slices of u8. // that are "strings" are expected to be UTF-8 encoded slices of u8.
// Here we coerce [5]u8 to []const u8 // Here we coerce *const [5:0]u8 and *const [6:0]u8 to []const u8
const hello: []const u8 = "hello"; const hello: []const u8 = "hello";
const world: []const u8 = "世界"; const world: []const u8 = "世界";