summaryrefslogtreecommitdiff
path: root/src/collection/ref.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/collection/ref.rs')
-rw-r--r--src/collection/ref.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/collection/ref.rs b/src/collection/ref.rs
index c3a0967..8b9e0f8 100644
--- a/src/collection/ref.rs
+++ b/src/collection/ref.rs
@@ -17,6 +17,11 @@ pub fn get_locks<L: Lockable>(data: &L) -> Vec<&dyn RawLock> {
/// returns `true` if the sorted list contains a duplicate
#[must_use]
fn contains_duplicates(l: &[&dyn RawLock]) -> bool {
+ if l.is_empty() {
+ // Return early to prevent panic in the below call to `windows`
+ return false;
+ }
+
l.windows(2)
.any(|window| std::ptr::eq(window[0], window[1]))
}