diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs index 89d5b2ff30f9f..b9fcc2365fa7c 100644 --- a/src/libstd/collections/hash/set.rs +++ b/src/libstd/collections/hash/set.rs @@ -627,7 +627,11 @@ impl HashSet /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn is_subset(&self, other: &HashSet) -> 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,