Commit Graph

11 Commits (56a905c7d16c79138b4581a84f1f844bce2f00eb)

Author SHA1 Message Date
Andrew Kelley e402455704
rename std lib files to new convention 2019-03-02 16:46:04 -05:00
Andrew Kelley c2db077574
std.debug.assert: remove special case for test builds
Previously, std.debug.assert would `@panic` in test builds,
if the assertion failed. Now, it's always `unreachable`.

This makes release mode test builds more accurately test
the actual code that will be run.

However this requires tests to call `std.testing.expect`
rather than `std.debug.assert` to make sure output is correct.

Here is the explanation of when to use either one, copied from
the assert doc comments:

Inside a test block, it is best to use the `std.testing` module
rather than assert, because assert may not detect a test failure
in ReleaseFast and ReleaseSafe mode. Outside of a test block, assert
is the correct function to use.

closes #1304
2019-02-08 18:23:38 -05:00
Matthew O'Connor fbd6a66ae7 camelCase std.rb.set_child to std.rb.setChild 2018-11-16 13:03:13 -05:00
Matthew O'Connor 007783753e Change rb functions to use snakeCase. 2018-11-16 09:21:48 -05:00
Jimmi Holst Christensen 8139c5a516
New Zig formal grammar (#1685)
Reverted #1628 and changed the grammar+parser of the language to not allow certain expr where types are expected
2018-11-13 05:08:37 -08:00
Jimmi Holst Christensen 378d3e4403
Solve the return type ambiguity (#1628)
Changed container and initializer syntax
* <container> { ... } -> <container> . { ... }
* <exrp> { ... } -> <expr> . { ...}
2018-10-15 09:51:15 -04:00
Shawn Landden 4bf54f3010
std/rb.zig: fix comment 2018-09-01 22:23:34 -07:00
Andrew Kelley fb6d3859e8
zig fmt 2018-08-27 19:25:40 -04:00
Shawn Landden 64a71be5c3 rb: some style fixes
avoid @import("std") as is the custom

compare function name
2018-08-10 21:46:30 -07:00
Shawn Landden 86b512c5cd mem: move enum Compare from rb to mem 2018-08-07 04:57:41 -07:00
Shawn Landden 5d2abf4402 std: add red-black tree implementation
This is to be used with @fieldParentPtr();

Example:

const rb = @import("std").rb;

const Number = struct {
    node: rb.Node,
    value: i32,
};

fn number(node: *rb.Node) *Number {
    @fieldParentPtr(Number, "node", node);
}

fn compare(l: *rb.Node, r: *rb.Node) rb.Compare {
    var left = number(l);
    var right = number(r);

    if (left.value < right.value) {
        return rb.Compare.LessThan;
    } else if (left.value == right.value) {
        return rb.Compare.Equal;
    } else if (left.value > right.value) {
        return rb.Compare.GreaterThan;
    }
    unreachable;
}
--

A version that caches rb.Tree.first() could be added in the future.
2018-08-06 22:18:44 -07:00