math_add.zig (332B) - Raw
1 const math = @import("std").math; 2 const print = @import("std").debug.print; 3 pub fn main() !void { 4 var byte: u8 = 255; 5 6 byte = if (math.add(u8, byte, 1)) |result| result else |err| { 7 print("unable to add one: {s}\n", .{@errorName(err)}); 8 return err; 9 }; 10 11 print("result: {}\n", .{byte}); 12 } 13 14 // exe=fail