aboutsummaryrefslogtreecommitdiff
path: root/exercises/29_errdefer.zig
diff options
context:
space:
mode:
authorDave Gauer <ratfactor@gmail.com>2021-02-15 19:32:00 -0500
committerGitHub <noreply@github.com>2021-02-15 19:32:00 -0500
commit09fd739efa9cee151c8300f53c422d8a72766d49 (patch)
tree45f2eba30d72f43df60cd9b053ebaea5dfe11f18 /exercises/29_errdefer.zig
parent0d212ecf5a9de1c0bb673a2b6a409de5a99a9d7b (diff)
parent304489ca1f465b5456fa8c21dd0ae4e4c6c48617 (diff)
downloadziglings-09fd739efa9cee151c8300f53c422d8a72766d49.tar.gz
ziglings-09fd739efa9cee151c8300f53c422d8a72766d49.tar.bz2
ziglings-09fd739efa9cee151c8300f53c422d8a72766d49.tar.xz
ziglings-09fd739efa9cee151c8300f53c422d8a72766d49.zip
Merge pull request #22 from quexxon/apply-zig-fmt
Apply `zig fmt` to exercises and generate remaining patch files
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;