diff --git a/src/external_trait_impls/rayon/set.rs b/src/external_trait_impls/rayon/set.rs
index d5f50d3b87..896be75b0a 100644
--- a/src/external_trait_impls/rayon/set.rs
+++ b/src/external_trait_impls/rayon/set.rs
@@ -256,7 +256,11 @@ where
///
/// This method runs in a potentially parallel fashion.
pub fn par_is_subset(&self, other: &Self) -> bool {
- self.into_par_iter().all(|x| other.contains(x))
+ if self.len() <= other.len() {
+ self.into_par_iter().all(|x| other.contains(x))
+ } else {
+ false
+ }
}
/// Returns `true` if the set is a superset of another,
diff --git a/src/raw/mod.rs b/src/raw/mod.rs
index 199bdf1205..84b343a7b2 100644
--- a/src/raw/mod.rs
+++ b/src/raw/mod.rs
@@ -145,7 +145,7 @@ fn h2(hash: u64) -> u8 {
/// (skipping over 1 group), then 3 groups (skipping over 2 groups), and so on.
///
/// Proof that the probe will visit every group in the table:
-/// https://fgiesen.wordpress.com/2015/02/22/triangular-numbers-mod-2n/
+///
struct ProbeSeq {
bucket_mask: usize,
pos: usize,
@@ -935,12 +935,12 @@ impl RawTable {
/// should be dropped using a `RawIter` before freeing the allocation.
#[inline]
pub fn into_alloc(self) -> Option<(NonNull, Layout)> {
- let alloc = if !self.is_empty_singleton() {
+ let alloc = if self.is_empty_singleton() {
+ None
+ } else {
let (layout, _) = calculate_layout::(self.buckets())
.unwrap_or_else(|| unsafe { hint::unreachable_unchecked() });
Some((self.ctrl.cast(), layout))
- } else {
- None
};
mem::forget(self);
alloc
diff --git a/src/set.rs b/src/set.rs
index 8659a256fd..ade77267ac 100644
--- a/src/set.rs
+++ b/src/set.rs
@@ -640,7 +640,11 @@ where
/// assert_eq!(set.is_subset(&sup), false);
/// ```
pub fn is_subset(&self, other: &Self) -> bool {
- self.iter().all(|v| other.contains(v))
+ if self.len() <= other.len() {
+ self.iter().all(|v| other.contains(v))
+ } else {
+ false
+ }
}
/// Returns `true` if the set is a superset of another,