authorgravatar for aznashwan@icloud.comNashwan Azhari <aznashwan@icloud.com> 2025-11-12 00:52:30+02:00
committergravatar for aznashwan@icloud.comNashwan Azhari <aznashwan@icloud.com> 2025-11-22 02:56:40+02:00
logaf7dec94c636769741e746090c9bd0590e3bbc22
tree1e0a2a88d1df10fd8dfae708562d4a3912f168f0
parent153521279f96dbbb3179c8b92138ad126626adf8
signaturebadge-check Signed by SSH key SHA256:iRciOOQUTS4+1xUmULDLGShiwKkzoXrV5G4FSLtVIH8

docs: use custom error set in `values.zig` sample.

Signed-off-by: Nashwan Azhari <aznashwan@icloud.com>

1 files changed, 6 insertions(+), 1 deletions(-)

doc/langref/values.zig+6-1
......@@ -4,6 +4,11 @@ const std = @import("std");
44const os = std.os;
55const assert = std.debug.assert;
66
7// Custom error set definition:
8const ExampleErrorSet = error{
9 ExampleErrorVariant,
10};
11
712pub fn main() void {
813 // integers
914 const one_plus_one: i32 = 1 + 1;
......@@ -36,7 +41,7 @@ pub fn main() void {
3641 });
3742
3843 // error union
39 var number_or_error: anyerror!i32 = error.ArgNotFound;
44 var number_or_error: ExampleErrorSet!i32 = ExampleErrorSet.ExampleErrorVariant;
4045
4146 print("\nerror union 1\ntype: {}\nvalue: {!}\n", .{
4247 @TypeOf(number_or_error),