diff --git a/crdt-lib/src/counter.zig b/crdt-lib/src/counter.zig index 5f1c8ad..80716cc 100644 --- a/crdt-lib/src/counter.zig +++ b/crdt-lib/src/counter.zig @@ -52,8 +52,7 @@ pub fn Counter(comptime T: type) type { /// Merges `other` into `self` by taking the element-wise max of each replica's count. /// - /// `self` is mutated in place; `other` is consumed by value. - /// Caller must deinit `other` after calling merge. + /// `self` is mutated in place; the caller retains ownership of `other`. pub fn merge(self: *Self, other: Self, gpa: Allocator) Allocator.Error!void { var it = other.counters.iterator(); while (it.next()) |entry| { diff --git a/crdt-lib/src/mv_register.zig b/crdt-lib/src/mv_register.zig index 1c19081..7333115 100644 --- a/crdt-lib/src/mv_register.zig +++ b/crdt-lib/src/mv_register.zig @@ -83,8 +83,7 @@ pub fn MvRegister(T: type) type { /// Merges `other` into `self`, retaining (value, tag) pairs that are not /// dominated by any other tag (same replica, higher seq). /// - /// `self` is mutated in place; `other` is consumed by value. - /// Caller must deinit `other` after calling merge. + /// `self` is mutated in place; the caller retains ownership of `other`. pub fn merge(self: *Self, other: Self, gpa: Allocator) Allocator.Error!void { if (other.values.items.len == 0) return; diff --git a/crdt-lib/src/or_set.zig b/crdt-lib/src/or_set.zig index d847406..4522a5c 100644 --- a/crdt-lib/src/or_set.zig +++ b/crdt-lib/src/or_set.zig @@ -104,8 +104,7 @@ pub fn OrSet(T: type) type { /// Merges `other` into `self` by unioning elements and tombstones, /// then removing tombstoned tags from the element sets. /// - /// `self` is mutated in place; `other` is consumed by value. - /// Caller must deinit `other` after calling merge. + /// `self` is mutated in place; the caller retains ownership of `other`. pub fn merge(self: *Self, other: Self, gpa: Allocator) Allocator.Error!void { // Merge other.elements into self.elements (union of tag sets) { diff --git a/crdt-lib/src/pn_counter.zig b/crdt-lib/src/pn_counter.zig index 8a325ee..005f290 100644 --- a/crdt-lib/src/pn_counter.zig +++ b/crdt-lib/src/pn_counter.zig @@ -58,8 +58,7 @@ pub fn PnCounter(comptime T: type) type { /// Merges `other` into `self` by merging pos and neg G-Counters independently. /// - /// `self` is mutated in place; `other` is consumed by value. - /// Caller must deinit `other` after calling merge. + /// `self` is mutated in place; the caller retains ownership of `other`. pub fn merge(self: *Self, other: Self, gpa: Allocator) Allocator.Error!void { try self.pos.merge(other.pos, gpa); try self.neg.merge(other.neg, gpa); diff --git a/crdt-lib/src/rga.zig b/crdt-lib/src/rga.zig index 029d904..68b6cbd 100644 --- a/crdt-lib/src/rga.zig +++ b/crdt-lib/src/rga.zig @@ -160,8 +160,7 @@ pub fn Rga(comptime T: type) type { /// /// If the same `Id` exists in both states, removal wins: /// the merged node is marked removed if either side removed it. - /// `self` is mutated in place; `other` is consumed by value. - /// Caller must deinit `other` after calling merge. + /// `self` is mutated in place; the caller retains ownership of `other`. pub fn merge(self: *Self, other: Self, gpa: Allocator) Allocator.Error!void { var it = other.nodes.iterator(); while (it.next()) |entry| { diff --git a/crdt-lib/src/root.zig b/crdt-lib/src/root.zig index 76830b8..0d17cb8 100644 --- a/crdt-lib/src/root.zig +++ b/crdt-lib/src/root.zig @@ -216,14 +216,10 @@ fn expectCrdtEqual(a: *Crdt, b: *Crdt, alloc: Allocator) !void { std.mem.sort(T, b_vals, {}, lessThan); try testing.expectEqual(a_vals.len, b_vals.len); - std.debug.print("len good\n", .{}); for (a_vals, b_vals) |av, bv| { try testing.expectEqual(av.value, bv.value); - std.debug.print("value good\n", .{}); try testing.expectEqual(av.tag.replica, bv.tag.replica); - std.debug.print("replica good\n", .{}); try testing.expectEqual(av.tag.seq, bv.tag.seq); - std.debug.print("seq good\n", .{}); } }, .rga => { diff --git a/crdt-lib/src/set.zig b/crdt-lib/src/set.zig index 756191d..f5c3107 100644 --- a/crdt-lib/src/set.zig +++ b/crdt-lib/src/set.zig @@ -53,8 +53,7 @@ pub fn Set(T: type) type { /// Merges `other` into `self` by taking the element-wise union. /// - /// `self` is mutated in place; `other` is consumed by value. - /// Caller must deinit `other` after calling merge. + /// `self` is mutated in place; the caller retains ownership of `other`. pub fn merge(self: *Self, other: Self, gpa: Allocator) Allocator.Error!void { var it = other.hashset.keyIterator(); while (it.next()) |k| {