| author | |
| committer | |
| log | d3cd0b27145fb9d295078a6883f9714769cb482b |
| tree | ddf7e7dc4fe9d8791f966b1db0a079697212997d |
| parent | 294db62d926ef82f2beb86e7e5ddf8d69092864a |
| parent | d90646d8fbd8658120c39bc2690088c0efa21157 |
| signature |
langref: make example more interesting.2 files changed, 7 insertions(+), 5 deletions(-)
doc/langref/defer_unwind.zig+2-3| ... | ... | @@ -1,8 +1,7 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const expect = std.testing.expect; | |
| 3 | 2 | const print = std.debug.print; |
| 4 | 3 | |
| 5 | test "defer unwinding" { | |
| 4 | pub fn main() void { | |
| 6 | 5 | print("\n", .{}); |
| 7 | 6 | |
| 8 | 7 | defer { |
| ... | ... | @@ -19,4 +18,4 @@ test "defer unwinding" { |
| 19 | 18 | } |
| 20 | 19 | } |
| 21 | 20 | |
| 22 | // test | |
| 21 | // exe=succeed |
doc/langref/inline_call.zig+5-2| ... | ... | @@ -1,11 +1,14 @@ |
| 1 | test "inline function call" { | |
| 1 | const std = @import("std"); | |
| 2 | ||
| 3 | pub fn main() void { | |
| 2 | 4 | if (foo(1200, 34) != 1234) { |
| 3 | 5 | @compileError("bad"); |
| 4 | 6 | } |
| 5 | 7 | } |
| 6 | 8 | |
| 7 | 9 | inline fn foo(a: i32, b: i32) i32 { |
| 10 | std.debug.print("runtime a = {} b = {}", .{ a, b }); | |
| 8 | 11 | return a + b; |
| 9 | 12 | } |
| 10 | 13 | |
| 11 | // test | |
| 14 | // exe=succeed |