zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 6fef362992826cea3fba991ad3d63aaaa59a2385 (tree)
parent 2d9c4792ae2cab0ff3b1df54b15913dcbcaef112
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Sun, 21 Jan 2024 16:36:27 -0700

Revert "langref: emphasize the use of dereferencing string literals"

This reverts commit 27353bb936a161e6a09f1424ce38bf84e78e94e4.

* unnecessary example
* poor phrasing (avoid "you")

Diffstat:
Mdoc/langref.html.in | 11+----------
1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/doc/langref.html.in b/doc/langref.html.in @@ -896,18 +896,9 @@ pub fn main() void { The type of string literals encodes both the length, and the fact that they are null-terminated, and thus they can be {#link|coerced|Type Coercion#} to both {#link|Slices#} and {#link|Null-Terminated Pointers|Sentinel-Terminated Pointers#}. + Dereferencing string literals converts them to {#link|Arrays#}. </p> <p> - Dereferencing string literals converts them to {#link|Arrays#}, allowing you to initialize a buffer with the contents of a string literal. - </p> - {#code_begin|syntax|mutable_string_buffer#} -test { - var buffer = [_]u8{0}**256; - const home_dir = "C:/Users/root"; - buffer[0..home_dir.len].* = home_dir.*; -} - {#code_end#} - <p> The encoding of a string in Zig is de-facto assumed to be UTF-8. Because Zig source code is {#link|UTF-8 encoded|Source Encoding#}, any non-ASCII bytes appearing within a string literal in source code carry their UTF-8 meaning into the content of the string in the Zig program;