mirror of
https://github.com/ziglang/zig.git
synced 2025-12-25 07:33:08 +00:00
I started working on #465 and made some corresponding std.io API changes. New structs: * std.io.FileInStream * std.io.FileOutStream * std.io.BufferedOutStream * std.io.BufferedInStream Removed: * std.io.File.in_stream * std.io.File.out_stream Now instead of &file.out_stream or &file.in_stream to get access to the stream API for a file, you get it like this: var file_in_stream = io.FileInStream.init(&file); const in_stream = &file_in_stream.stream; var file_out_stream = io.FileOutStream.init(&file); const out_stream = &file_out_stream.stream; This is evidence that we might not need any OOP features - See #130.
10 lines
330 B
Zig
10 lines
330 B
Zig
const std = @import("std");
|
|
|
|
pub fn main() -> %void {
|
|
// If this program is run without stdout attached, exit with an error.
|
|
var stdout_file = %return std.io.getStdOut();
|
|
// If this program encounters pipe failure when printing to stdout, exit
|
|
// with an error.
|
|
%return stdout_file.write("Hello, world!\n");
|
|
}
|