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..930b3e2c01 100644 --- a/src/raw/mod.rs +++ b/src/raw/mod.rs @@ -118,11 +118,8 @@ fn special_is_empty(ctrl: u8) -> bool { #[inline] #[allow(clippy::cast_possible_truncation)] fn h1(hash: u64) -> usize { - #[cfg(target_pointer_width = "32")] - { - debug_assert!(hash <= u64::from(u32::max_value())); - } - hash as usize // truncation + // On 32-bit platforms we simply ignore the higher hash bits. + hash as usize } /// Secondary hash function, saved in the low 7 bits of the control byte. 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,