zig/doc/langref/defer_unwind.zig

23 lines
379 B
Zig

const std = @import("std");
const expect = std.testing.expect;
const print = std.debug.print;
test "defer unwinding" {
print("\n", .{});
defer {
print("1 ", .{});
}
defer {
print("2 ", .{});
}
if (false) {
// defers are not run if they are never executed.
defer {
print("3 ", .{});
}
}
}
// test