From 2f821bd5e83129445179ea7bd81260df74fff295 Mon Sep 17 00:00:00 2001 From: Will Clardy Date: Mon, 15 Feb 2021 16:55:44 -0500 Subject: Apply `zig fmt` to exercises --- exercises/29_errdefer.zig | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'exercises/29_errdefer.zig') 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; -- cgit v1.2.3-ZIG