I have saw the part of the source code in the std/io.zig
pub fn getStdOut() GetStdIoErrs!File {
const handle = if (is_windows) try os.windowsGetStdHandle(os.windows.STD_OUTPUT_HANDLE) else if (is_posix) os.posix.STDOUT_FILENO else unreachable;
return File.openHandle(handle);
}
I think the return type is like !std.io.File so I write follow code:
fn getStdOut() !std.io.File{
return std.io.getStdOut();
}
But it is not work:
xxx/h.zig:11:23: error: 'File' is private
fn getStdOut() !std.io.File{
^
/usr/local/zig/build/lib/zig/std/io.zig:13:1: note: declared here
const File = std.os.File;
So I have to change the code like this(it works):
fn getStdOut() !std.os.File{
return std.io.getStdOut();
}
So I have follow proposal:
- If you set a function public, all the input and output parameter type must be public, or you will get a compile error.
This proposal will make reading code easier.
I have saw the part of the source code in the
std/io.zigI think the return type is like
!std.io.Fileso I write follow code:But it is not work:
So I have to change the code like this(it works):
So I have follow proposal:
This proposal will make reading code easier.