Git Product home page Git Product logo

tres's Issues

Add `tres_null_meaning`

pub const A = struct {
    pub const tres_null_meaning = .{.{"a", .field}, .{"b", .null}, .{"c", .dual}};
    a: ?u8 = null,
    b: ?u8 = null,
    c: ??u8 = @as(?u8, null),
};

becomes

{"b": null, "c": null}

Useful for differentiating between abc? fields and abc: ... | null LSP fields.

?? dual fields are non-existent on the first null, then null on the second null. This eliminates the need for Undefinedable which is just super clunky to use.

`??T` on bare struct causes compile error

pub const Document = struct {
    revision: ??[]const u8,
    description: ??[]const u8,
};

parsing the preceding results in this compile error:

/Users/haze/.cache/zig/p/1220beaae8d152baa941a10b7ef3d3a59d093b257047035e2373c3c2f876ad29ccc8/tres.zig:549:69: error: unable to evaluate comptime expression
                    } else if (comptime dualable(field.type) and nm == .dual) {
                                                                 ~~~^~~~~~~~
/Users/haze/.cache/zig/p/1220beaae8d152baa941a10b7ef3d3a59d093b257047035e2373c3c2f876ad29ccc8/tres.zig:549:66: note: operation is runtime due to this operand
                    } else if (comptime dualable(field.type) and nm == .dual) {

(parsed like so)

    var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
    defer arena.deinit();

    var parser = std.json.Parser.init(arena.allocator(), false);
    const tree = try parser.parse(data);

    const document = try tres.parse(Document, tree.root, arena.allocator());
    std.log.warn("{}", .{document});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.