mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
Merge pull request #24537 from IOKG04/some-documentation-updates-0
some small langref changes
This commit is contained in:
commit
032bbd68a7
3 changed files with 13 additions and 4 deletions
|
|
@ -3215,7 +3215,7 @@ fn createFoo(param: i32) !Foo {
|
||||||
to increase their development pace.
|
to increase their development pace.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
Error Return Traces are enabled by default in {#link|Debug#} and {#link|ReleaseSafe#} builds and disabled by default in {#link|ReleaseFast#} and {#link|ReleaseSmall#} builds.
|
Error Return Traces are enabled by default in {#link|Debug#} builds and disabled by default in {#link|ReleaseFast#}, {#link|ReleaseSafe#} and {#link|ReleaseSmall#} builds.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
There are a few ways to activate this error return tracing feature:
|
There are a few ways to activate this error return tracing feature:
|
||||||
|
|
@ -4840,7 +4840,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
|
||||||
<p>
|
<p>
|
||||||
This builtin can be called from a {#link|comptime#} block to conditionally export symbols.
|
This builtin can be called from a {#link|comptime#} block to conditionally export symbols.
|
||||||
When <code>ptr</code> points to a function with the C calling convention and
|
When <code>ptr</code> points to a function with the C calling convention and
|
||||||
{#syntax#}options.linkage{#endsyntax#} is {#syntax#}.Strong{#endsyntax#}, this is equivalent to
|
{#syntax#}options.linkage{#endsyntax#} is {#syntax#}.strong{#endsyntax#}, this is equivalent to
|
||||||
the {#syntax#}export{#endsyntax#} keyword used on a function:
|
the {#syntax#}export{#endsyntax#} keyword used on a function:
|
||||||
</p>
|
</p>
|
||||||
{#code|export_builtin.zig#}
|
{#code|export_builtin.zig#}
|
||||||
|
|
@ -5179,7 +5179,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
|
||||||
<pre>{#syntax#}@mod(numerator: T, denominator: T) T{#endsyntax#}</pre>
|
<pre>{#syntax#}@mod(numerator: T, denominator: T) T{#endsyntax#}</pre>
|
||||||
<p>
|
<p>
|
||||||
Modulus division. For unsigned integers this is the same as
|
Modulus division. For unsigned integers this is the same as
|
||||||
{#syntax#}numerator % denominator{#endsyntax#}. Caller guarantees {#syntax#}denominator > 0{#endsyntax#}, otherwise the
|
{#syntax#}numerator % denominator{#endsyntax#}. Caller guarantees {#syntax#}denominator != 0{#endsyntax#}, otherwise the
|
||||||
operation will result in a {#link|Remainder Division by Zero#} when runtime safety checks are enabled.
|
operation will result in a {#link|Remainder Division by Zero#} when runtime safety checks are enabled.
|
||||||
</p>
|
</p>
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -5284,7 +5284,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
|
||||||
<pre>{#syntax#}@rem(numerator: T, denominator: T) T{#endsyntax#}</pre>
|
<pre>{#syntax#}@rem(numerator: T, denominator: T) T{#endsyntax#}</pre>
|
||||||
<p>
|
<p>
|
||||||
Remainder division. For unsigned integers this is the same as
|
Remainder division. For unsigned integers this is the same as
|
||||||
{#syntax#}numerator % denominator{#endsyntax#}. Caller guarantees {#syntax#}denominator > 0{#endsyntax#}, otherwise the
|
{#syntax#}numerator % denominator{#endsyntax#}. Caller guarantees {#syntax#}denominator != 0{#endsyntax#}, otherwise the
|
||||||
operation will result in a {#link|Remainder Division by Zero#} when runtime safety checks are enabled.
|
operation will result in a {#link|Remainder Division by Zero#} when runtime safety checks are enabled.
|
||||||
</p>
|
</p>
|
||||||
<ul>
|
<ul>
|
||||||
|
|
|
||||||
|
|
@ -67,4 +67,11 @@ test "*T to *[1]T" {
|
||||||
try expect(z[0] == 1234);
|
try expect(z[0] == 1234);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sentinel-terminated slices can be coerced into sentinel-terminated pointers
|
||||||
|
test "[:x]T to [*:x]T" {
|
||||||
|
const buf: [:0]const u8 = "hello";
|
||||||
|
const buf2: [*:0]const u8 = buf;
|
||||||
|
try expect(buf2[4] == 'o');
|
||||||
|
}
|
||||||
|
|
||||||
// test
|
// test
|
||||||
|
|
|
||||||
|
|
@ -525,6 +525,8 @@ fn testIntDivision() !void {
|
||||||
try expect(rem(i32, 10, 12) == 10);
|
try expect(rem(i32, 10, 12) == 10);
|
||||||
try expect(rem(i32, -14, 12) == -2);
|
try expect(rem(i32, -14, 12) == -2);
|
||||||
try expect(rem(i32, -2, 12) == -2);
|
try expect(rem(i32, -2, 12) == -2);
|
||||||
|
try expect(rem(i32, 118, -12) == 10);
|
||||||
|
try expect(rem(i32, -14, -12) == -2);
|
||||||
try expect(rem(i16, -118, 12) == -10);
|
try expect(rem(i16, -118, 12) == -10);
|
||||||
|
|
||||||
try expect(divTrunc(i20, 20, -5) == -4);
|
try expect(divTrunc(i20, 20, -5) == -4);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue