From fc448cf3f4f0927078f74974bac75bca0e874946 Mon Sep 17 00:00:00 2001 From: ToMe25 Date: Fri, 7 Jun 2024 15:32:46 +0200 Subject: [PATCH] Optimize Set is_disjoint --- src/set.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/set.rs b/src/set.rs index bd98af7d0..7760bfd3b 100644 --- a/src/set.rs +++ b/src/set.rs @@ -1044,7 +1044,7 @@ where /// assert_eq!(a.is_disjoint(&b), false); /// ``` pub fn is_disjoint(&self, other: &Self) -> bool { - self.iter().all(|v| !other.contains(v)) + self.intersection(other).next().is_none() } /// Returns `true` if the set is a subset of another,