Skip to content

Commit

Permalink
Optimize Set is_disjoint
Browse files Browse the repository at this point in the history
  • Loading branch information
ToMe25 committed Jun 7, 2024
1 parent 2310a95 commit fc448cf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit fc448cf

Please sign in to comment.