Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,19 @@
const std = @import("std");
// To replace exceptions, Zig has error enums to handle error states.
pub fn main() !void {
// writing to stdout as file descriptor might fail,
// if we are a child process and the parent process has closed it
const stdout_wr = std.io.getStdOut().writer();
try stdout_wr.writeAll("a");
// Above code is identical to
stdout_wr.writeAll("a") catch |err| return err;
stdout_wr.writeAll("a") catch |err| {
// usually std streams are leaked and the Kernel cleans them up
var stdin = std.io.getStdIn();
var stderr = std.io.getStdErr();
stdin.close();
stderr.close();
return err;
};
}