langref: avoid the ambiguous word "safe"

See #2402
This commit is contained in:
Andrew Kelley 2024-01-18 20:58:35 -07:00
parent 9e6ff71330
commit 8662c0ff43

View File

@ -2788,9 +2788,11 @@ test "volatile" {
</p> </p>
{#header_close#} {#header_close#}
<p> <p>
To convert one pointer type to another, use {#link|@ptrCast#}. This is an unsafe {#link|@ptrCast#} converts a pointer's element type to another. This
operation that Zig cannot protect you against. Use {#syntax#}@ptrCast{#endsyntax#} only when other creates a new pointer that can cause undetectable illegal behavior
conversions are not possible. depending on the loads and stores that pass through it. Generally, other
kinds of type conversions are preferable to
{#syntax#}@ptrCast{#endsyntax#} if possible.
</p> </p>
{#code_begin|test|test_pointer_casting#} {#code_begin|test|test_pointer_casting#}
const std = @import("std"); const std = @import("std");
@ -8592,7 +8594,8 @@ test "decl access by string" {
<pre>{#syntax#}@floatFromInt(int: anytype) anytype{#endsyntax#}</pre> <pre>{#syntax#}@floatFromInt(int: anytype) anytype{#endsyntax#}</pre>
<p> <p>
Converts an integer to the closest floating point representation. The return type is the inferred result type. Converts an integer to the closest floating point representation. The return type is the inferred result type.
To convert the other way, use {#link|@intFromFloat#}. This cast is always safe. To convert the other way, use {#link|@intFromFloat#}. This operation is legal
for all values of all integer types.
</p> </p>
{#header_close#} {#header_close#}