aboutsummaryrefslogtreecommitdiff
path: root/exercises/29_errdefer.zig
diff options
context:
space:
mode:
authorWill Clardy <will@quexxon.net>2021-02-15 16:55:44 -0500
committerWill Clardy <will@quexxon.net>2021-02-15 16:55:44 -0500
commit2f821bd5e83129445179ea7bd81260df74fff295 (patch)
tree4f88d7f715dcd0bc98d20f3b7f70d49f2bdcb408 /exercises/29_errdefer.zig
parente58f155bd6261a0c1408e8bb3b177bbced828eb3 (diff)
downloadziglings-2f821bd5e83129445179ea7bd81260df74fff295.tar.gz
ziglings-2f821bd5e83129445179ea7bd81260df74fff295.tar.bz2
ziglings-2f821bd5e83129445179ea7bd81260df74fff295.tar.xz
ziglings-2f821bd5e83129445179ea7bd81260df74fff295.zip
Apply `zig fmt` to exercises
Diffstat (limited to 'exercises/29_errdefer.zig')
-rw-r--r--exercises/29_errdefer.zig9
1 files changed, 4 insertions, 5 deletions
diff --git a/exercises/29_errdefer.zig b/exercises/29_errdefer.zig
index cd2158d..f43c738 100644
--- a/exercises/29_errdefer.zig
+++ b/exercises/29_errdefer.zig
@@ -15,7 +15,6 @@
//
const std = @import("std");
-//
var counter: u32 = 0;
const MyErr = error{ GetFail, IncFail };
@@ -25,8 +24,8 @@ pub fn main() void {
var a: u32 = makeNumber() catch return;
var b: u32 = makeNumber() catch return;
- std.debug.print("Numbers: {}, {}\n", .{a,b});
-}
+ std.debug.print("Numbers: {}, {}\n", .{ a, b });
+}
fn makeNumber() MyErr!u32 {
std.debug.print("Getting number...", .{});
@@ -35,7 +34,7 @@ fn makeNumber() MyErr!u32 {
// function exits with an error:
std.debug.print("failed!\n", .{});
- var num = try getNumber(); // <-- This could fail!
+ var num = try getNumber(); // <-- This could fail!
num = try increaseNumber(num); // <-- This could ALSO fail!
@@ -52,7 +51,7 @@ fn getNumber() MyErr!u32 {
fn increaseNumber(n: u32) MyErr!u32 {
// I fail after the first time you run me!
if (counter > 0) return MyErr.IncFail;
-
+
// Sneaky, weird global stuff.
counter += 1;