5 ms·
You can't not `try` or `catch`. So if you made a separate function you'd just be doing all of those `try`-es line by line in that other function. const std
by eatonphil 4y ago
You can't not `try` or `catch`. So if you made a separate function you'd just be doing all of those `try`-es line by line in that other function.
const std = @import("std");
fn thing(a: std.mem.Allocator) !void {
std.fmt.allocPrint(a, "", .{});
}
pub fn main() !void {
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena.deinit();
const allocator = arena.allocator();
try thing(allocator);
}
Running `zig build-exe test.zig`:
test.zig:4:23: error: error is ignored
std.fmt.allocPrint(a, "", .{});
~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
test.zig:4:23: note: consider using 'try', 'catch', or 'if'
referenced by:
main: test.zig:12:9
callMain: /home/phil/vendor/zig-linux-x86_64-0.11.0-dev.2213+515e1c93e/lib/std/start.zig:617:32
remaining reference traces hidden; use '-freference-trace' to see all reference traces
I'll add this to the post.
- deleted 4y ago[deleted]