~alva/zig-bare

f87375e74f7863c377945d32b1e9d3bd951b5123 — Alva 4 months ago e881336 0.4.0
Add note on hash maps to README
2 files changed, 9 insertions(+), 2 deletions(-)

M README.md
M src/main.zig
M README.md => README.md +8 -1
@@ 38,7 38,7 @@ const x = Bar{
    .c = Foo{ .y = "hello" },
};

var buf: [@sizeOf(Bar)]u8 = undefined;
var buf: [12]u8 = undefined;
var fbs = io.fixedBufferStream(&buf);

try Writer.init().write(x, fbs.outStream());


@@ 53,6 53,13 @@ Hash maps and slices require allocation;
call `deinit` on a `Reader` to free any memory that was allocated,
if hash maps or slices are used.

### A note on hash maps

Since `std.HashMap` returns a `struct`, compile-time duck-typing is used to
detect if a `struct` is a hash map.
If/when Zig gains support for some form of traits or interfaces,
those will be used instead.

## BARE conformance

All BARE types are supported, although `data<length>` and `data` are the same

M src/main.zig => src/main.zig +1 -1
@@ 30,7 30,7 @@ pub fn main() !void {
        .c = .{ .y = "hello" },
    };

    var buf: [@sizeOf(Bar)]u8 = undefined;
    var buf: [12]u8 = undefined;
    var fbs = io.fixedBufferStream(&buf);

    try Writer.init().write(x, fbs.outStream());