File tree Expand file tree Collapse file tree 2 files changed +62
-0
lines changed Expand file tree Collapse file tree 2 files changed +62
-0
lines changed Original file line number Diff line number Diff line change @@ -401,6 +401,14 @@ export default defineConfig({
401
401
text : 'Never Confused: Rust, Zig and Go' ,
402
402
link : '/blog/rust-zig-go'
403
403
} ,
404
+ {
405
+ text : 'Start with Zig' ,
406
+ link : '/blog/zig' ,
407
+ } ,
408
+ {
409
+ text : 'Tauri' ,
410
+ link : '/blog/tauri' ,
411
+ } ,
404
412
{
405
413
text : "博客文章阅读系列" ,
406
414
collapsed : true ,
Original file line number Diff line number Diff line change
1
+ ---
2
+ title : " Start with Zig"
3
+ page : true
4
+ aside : true
5
+ ---
6
+
7
+ # Start with Zig
8
+
9
+ ## Resolve Error
10
+ ``` zig
11
+
12
+ pub fn main() !void {
13
+ const v: u32 = caused_error_fn() catch 4;
14
+ }
15
+ ```
16
+
17
+ ``` zig
18
+
19
+ pub fn main() !void {
20
+ const v: u32 = caused_error_fn() catch brk: {
21
+ break :brk 4;
22
+ }
23
+ }
24
+ ```
25
+
26
+ ``` zig
27
+
28
+ pub fn main() !void {
29
+ const v: u32 = caused_error_fn() catch |err| brk: {
30
+ if (err == error.OutOfMemory) {
31
+ break :brk 4;
32
+ }
33
+ break :brk 10;
34
+ }
35
+ }
36
+ ```
37
+
38
+ ``` zig
39
+
40
+ pub fn main() !void {
41
+ // program will panic if there is an error
42
+ const v: u32 = caused_error_fn() catch unreachable;
43
+ }
44
+ ```
45
+
46
+ ``` zig
47
+
48
+ pub fn main() !void {
49
+ const v: u32 = caused_error_fn() catch |err| switch(err) {
50
+ error.FileNotFound => return,
51
+ else => |e| { return e; },
52
+ }
53
+ }
54
+ ```
You can’t perform that action at this time.
0 commit comments