diff --git a/src/sync.rs b/src/sync.rs index cf236ab..bb9e608 100644 --- a/src/sync.rs +++ b/src/sync.rs @@ -841,6 +841,26 @@ impl LockFreeFrozenVec { } } +impl PartialEq for LockFreeFrozenVec { + fn eq(&self, other: &Self) -> bool { + // first check the length + let self_len = self.len.load(Ordering::Acquire); + let other_len = other.len.load(Ordering::Acquire); + if self_len != other_len { + return false; + } + + // Since the lengths are the same, just check the elements in order + for index in 0..self_len { + // This is safe because the indices are in bounds (for `LockFreeFrozenVec` the bounds can only grow). + if self.get(index) != other.get(index) { + return false; + } + } + return true; + } +} + #[test] fn test_non_lockfree_unchecked() { #[derive(Copy, Clone, Debug, PartialEq, Eq)]