News for hackers. Stuff that matters.
Re:Why I rewrote my Rust keyboard firmware in Zig: consisten... by steveklabnik on Sunday March 07, 2021 @06:37PM (#26380866)
You are not misunderstanding what Zig allows, but Rust can do the same thing. https://doc.rust-lang.org/stable/core/alloc/trait.Allocator.... just isn't stable yet. And it's conventional for it to take this as an argument for everything that needs it in Zig.

BufWrite would do it the same as any data structure would, an additional parameter, all the same.

Re:Why I rewrote my Rust keyboard firmware in Zig: consisten... by glandium on Sunday March 07, 2021 @06:46PM (#26380919)
I actually did misunderstand. I thought it allowed callers to give an allocator and the callees didn't have to know for it to be used.
Re:Why I rewrote my Rust keyboard firmware in Zig: consisten... by yellowapple on Sunday March 07, 2021 @10:10PM (#26381975)
I mean, I'd say you were mostly right, in the sense that the callee doesn't know the implementation details of the passed allocator; it's only aware of the interface (i.e. the struct of function pointers that defines that interface).