aboutsummaryrefslogtreecommitdiff
path: root/lib/std/rb.zig
diff options
context:
space:
mode:
authorShawn Landden <shawn@git.icu>2020-01-19 23:35:56 +0400
committerShawn Landden <shawn@git.icu>2020-01-19 23:35:56 +0400
commitad15a73240324fce93a659fbee9dab7be24dfbb0 (patch)
treea77dc093e4758766d6bf4194cc5254656a8a6a71 /lib/std/rb.zig
parent4ab9678b9553d77bc0683ee69a8936524f6a7808 (diff)
downloadzig-ad15a73240324fce93a659fbee9dab7be24dfbb0.tar.gz
zig-ad15a73240324fce93a659fbee9dab7be24dfbb0.zip
rb: type Tree.sort with SortError
Diffstat (limited to 'lib/std/rb.zig')
-rw-r--r--lib/std/rb.zig3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/std/rb.zig b/lib/std/rb.zig
index 78e1e3aedd..d7840b75b0 100644
--- a/lib/std/rb.zig
+++ b/lib/std/rb.zig
@@ -11,6 +11,7 @@ const Red = Color.Red;
const Black = Color.Black;
const ReplaceError = error{NotEqual};
+const SortError = error{NotUnique}; // The new comparison function results in duplicates.
/// Insert this into your struct that you want to add to a red-black tree.
/// Do not use a pointer. Turn the *rb.Node results of the functions in rb
@@ -135,7 +136,7 @@ pub const Tree = struct {
compareFn: fn (*Node, *Node, *Tree) Order,
/// Re-sorts a tree with a new compare function
- pub fn sort(tree: *Tree, newCompareFn: fn (*Node, *Node, *Tree) Order) !void {
+ pub fn sort(tree: *Tree, newCompareFn: fn (*Node, *Node, *Tree) Order) SortError!void {
var newTree = Tree.init(newCompareFn);
var node: *Node = undefined;
while (true) {