创建 json 写入流无法编译
Creating a json write stream doesn't compile
我正在尝试在 zig 中使用 JSON,但我不明白为什么它不能编译:
const file = std.fs.cwd().createFile("Hello", .{.read = true}) catch unreachable;
const stream = std.json.writeStream(std.fs.File.Writer, 5000000);
_ = stream;
错误:
error: parameter of type 'type' must be declared comptime
pub fn init(stream: OutStream) Self {
std.json.writeStream
想要一个写入流的实例,您应该传递给它 file.writer()
而不是 std.fs.File.Writer
.
我正在尝试在 zig 中使用 JSON,但我不明白为什么它不能编译:
const file = std.fs.cwd().createFile("Hello", .{.read = true}) catch unreachable;
const stream = std.json.writeStream(std.fs.File.Writer, 5000000);
_ = stream;
错误:
error: parameter of type 'type' must be declared comptime
pub fn init(stream: OutStream) Self {
std.json.writeStream
想要一个写入流的实例,您应该传递给它 file.writer()
而不是 std.fs.File.Writer
.