rangemap: CamelCase the error

This commit is contained in:
Eugene Rossokha
2025-03-24 21:58:46 +02:00
parent 84e05bb89b
commit ac3d052c2f
+10 -9
View File
@@ -25,6 +25,12 @@ pub fn RangeMap(
}
};
pub const Error = error{
ScalarOutOfRange,
RangeOutOfBounds,
} || Tree.Error;
pub const WalkFn = fn (*const Node) void;
pub const Iterator = struct {
@@ -41,11 +47,6 @@ pub fn RangeMap(
pub const Tree = BTree(Node, compare_fn, deinit_node_fn);
pub const Error = error{
scalar_out_of_range,
range_out_of_bounds,
} || Tree.Error;
fn compare_fn(a: *const Node, b: *const Node) Order {
return Range(K).compare_disjoint(&a.key, &b.key);
}
@@ -98,14 +99,14 @@ pub fn RangeMap(
///
/// # Errors
///
/// * `scalar_out_of_range` if the given `at` value is not inside the node's interval.
/// * `ScalarOutOfRange` if the given `at` value is not inside the node's interval.
pub fn split_node(
self: *@This(),
node: *Tree.Node,
at: K,
) Error!?struct { *Tree.Node, *Tree.Node } {
if (!node.key.key.contains(at)) {
return error.scalar_out_of_range;
return error.ScalarOutOfRange;
}
const start = node.key.key.start;
@@ -195,7 +196,7 @@ pub fn RangeMap(
fn validate_range(start: K, end: K) Error!void {
// Check for addition overflowing the K's bit size
if (std.math.add(K, start, end) == error.Overflow) {
return error.range_out_of_bounds;
return error.RangeOutOfBounds;
}
}
};
@@ -446,5 +447,5 @@ test "Range map should disallow overflowing ranges" {
var map = Map.init(std.testing.allocator);
defer map.deinit();
try std.testing.expectError(error.range_out_of_bounds, map.insert(0xF0000000, 0x20000000, false));
try std.testing.expectError(error.RangeOutOfBounds, map.insert(0xF0000000, 0x20000000, false));
}