authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-07-15 08:51:56+02:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2025-07-15 08:51:56+02:00
logd3cd0b27145fb9d295078a6883f9714769cb482b
treeddf7e7dc4fe9d8791f966b1db0a079697212997d
parent294db62d926ef82f2beb86e7e5ddf8d69092864a
parentd90646d8fbd8658120c39bc2690088c0efa21157
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #24448 from matklad/matklad/inline

langref: make example more interesting.

2 files changed, 7 insertions(+), 5 deletions(-)

doc/langref/defer_unwind.zig+2-3
...@@ -1,8 +1,7 @@...@@ -1,8 +1,7 @@
1const std = @import("std");1const std = @import("std");
2const expect = std.testing.expect;
3const print = std.debug.print;2const print = std.debug.print;
43
5test "defer unwinding" {4pub fn main() void {
6 print("\n", .{});5 print("\n", .{});
76
8 defer {7 defer {
...@@ -19,4 +18,4 @@ test "defer unwinding" {...@@ -19,4 +18,4 @@ test "defer unwinding" {
19 }18 }
20}19}
2120
22// test21// exe=succeed
doc/langref/inline_call.zig+5-2
...@@ -1,11 +1,14 @@...@@ -1,11 +1,14 @@
1test "inline function call" {1const std = @import("std");
2
3pub fn main() void {
2 if (foo(1200, 34) != 1234) {4 if (foo(1200, 34) != 1234) {
3 @compileError("bad");5 @compileError("bad");
4 }6 }
5}7}
68
7inline fn foo(a: i32, b: i32) i32 {9inline fn foo(a: i32, b: i32) i32 {
10 std.debug.print("runtime a = {} b = {}", .{ a, b });
8 return a + b;11 return a + b;
9}12}
1013
11// test14// exe=succeed