In sorted_vector_map v0.2.0, SortedVectorSet::is_subset appears to implement the opposite relation.
Current docs:
self is a subset of other (i.e. self ⊆ other)
Current code:
pub fn is_subset(&self, other: &SortedVectorSet<T>) -> bool {
other.difference(self).next().is_none()
}
other.difference(self).is_empty() checks whether other ⊆ self, so the implementation is reversed.
is_superset delegates to other.is_subset(self), so it becomes reversed as well.
Repro
use sorted_vector_map::sorted_vector_set;
#[test]
fn subset_semantics() {
let a = sorted_vector_set! { 1, 2 };
let b = sorted_vector_set! { 1, 2, 3 };
assert!(a.is_subset(&b)); // expected true
assert!(!b.is_subset(&a)); // expected false
assert!(b.is_superset(&a)); // expected true
assert!(!a.is_superset(&b)); // expected false
}
Suggested fix
pub fn is_subset(&self, other: &SortedVectorSet<T>) -> bool {
self.difference(other).next().is_none()
}
This matches the doc comment and standard set semantics.
In
sorted_vector_mapv0.2.0,SortedVectorSet::is_subsetappears to implement the opposite relation.Current docs:
selfis a subset ofother(i.e.self ⊆ other)Current code:
other.difference(self).is_empty()checks whetherother ⊆ self, so the implementation is reversed.is_supersetdelegates toother.is_subset(self), so it becomes reversed as well.Repro
Suggested fix
This matches the doc comment and standard set semantics.