Compatibility: HashSet
Spec: docs/spec/hashset.md, docs/spec/set-algebra.md, docs/spec/hashing.md. Legend and
01: labels: ../COMPAT.md. GenericHashSet rows are in crate.md,
HashSetPool rows in features.md. OrdSet: From<HashSet> rows are in ordset.md.
Not items, recorded for completeness: there is no HashSet::iter_mut (removed in im 15.0) and
no HashSet::get in im 15.1 or imbl 7; perennial adds neither.
Type, constructors, hasher, size
| item | im 15.1 | imbl 7 | perennial | status | test |
|---|---|---|---|---|---|
HashSet<A, S = RandomState> (type) |
struct with hasher parameter | alias HashSet<A> only |
alias of GenericHashSet<A, S, P> keeping S = RandomState (01:generic) |
same | tests/compat_hashset.rs::hash_set_type |
new() -> Self |
fresh RandomState |
as im | as im (needs feature std) |
same | tests/compat_hashset.rs::new |
with_pool(pool: &HashSetPool<A>) -> Self |
im-rc pool |
absent | size-only handle | differs: pool does not pool allocations (01:pools) | tests/compat_hashset_features.rs::with_pool |
unit(a: A) -> Self |
one element | as im | as im | same | tests/compat_hashset.rs::unit |
with_hasher<RS>(h: RS) -> Self |
accepts S or the pointer |
takes S |
accepts anything Into<Ptr<S>> (01:bounds) |
same | tests/compat_hashset.rs::with_hasher |
with_pool_hasher<RS>(pool, h: RS) -> Self |
im-rc pool |
absent | size-only handle | differs: pool does not pool allocations (01:pools) | tests/compat_hashset_features.rs::with_pool_hasher |
hasher(&self) -> &Rc<S> / &Arc<S> |
&S |
&Ptr<S> (01:bounds) |
same | tests/compat_hashset.rs::hasher |
|
new_from<A1>(&self) -> HashSet<A1, S> |
empty set sharing the hasher | parameter named A2 |
as im | same | tests/compat_hashset.rs::new_from |
pool(&self) -> &HashSetPool<A> |
im-rc pool |
absent | size-only handle | differs: handle only (01:pools) | tests/compat_hashset_features.rs::pool |
is_empty(&self) -> bool |
O(1) | as im | as im | same | tests/compat_hashset.rs::is_empty |
len(&self) -> usize |
O(1) | as im | as im | same | tests/compat_hashset.rs::len |
ptr_eq(&self, other: &Self) -> bool |
two empty → false | two empty → true | two empty → true | differs: empty sets are ptr_eq (01:ptr_eq-empty) |
tests/compat_hashset.rs::ptr_eq |
clear(&mut self) |
O(n) | as im | as im | same | tests/compat_hashset.rs::clear |
iter(&self) -> Iter<'_, A> |
hash order, stable per set value | as im | order contract of hashing.md | same | tests/differential/hashset.rs |
Queries, mutation, persistent operations
| item | im 15.1 | imbl 7 | perennial | status | test |
|---|---|---|---|---|---|
contains<BA>(&self, a: &BA) -> bool |
Borrow bounds |
Equivalent bounds |
Borrow bounds (01:bounds) |
same | tests/compat_hashset.rs::contains |
is_subset<RS>(&self, other: RS) -> bool |
as im | as im | same | tests/compat_hashset.rs::is_subset |
|
is_proper_subset<RS>(&self, other: RS) -> bool |
subset and strictly smaller | as im | as im | same | tests/compat_hashset.rs::is_proper_subset |
insert(&mut self, a: A) -> Option<A> |
returns the old equal element and stores the new one | as im | as im | same | tests/compat_hashset.rs::insert |
remove<BA>(&mut self, a: &BA) -> Option<A> |
as im | as im | same | tests/compat_hashset.rs::remove |
|
update(&self, a: A) -> Self |
persistent insert | as im | as im | same | tests/compat_hashset.rs::update |
without<BA>(&self, a: &BA) -> Self |
persistent remove | as im | as im | same | tests/compat_hashset.rs::without |
retain(&mut self, f: FnMut(&A) -> bool) |
as im | as im | same | tests/compat_hashset.rs::retain |
|
union(self, other: Self) -> Self |
element from the smaller operand stored; other's on a tie |
as im | as im (01 decides only map value priority) | same | tests/compat_hashset.rs::union |
unions(i: impl IntoIterator<Item = Self>) -> Self |
as im | as im | same | tests/compat_hashset.rs::unions |
|
difference(self, other: Self) -> Self |
symmetric difference (alias) | deprecated | deprecated, same meaning | differs: deprecation warning only (01:difference) | tests/compat_hashset.rs::difference |
symmetric_difference(self, other: Self) -> Self |
as im | as im | same | tests/compat_hashset.rs::symmetric_difference |
|
relative_complement(self, other: Self) -> Self |
in self, not in other | as im | as im | same | tests/compat_hashset.rs::relative_complement |
intersection(self, other: Self) -> Self |
equal-size pair stored other's element |
as im | as im | same | tests/compat_hashset.rs::intersection |
Iterators (not double-ended)
| item | im 15.1 | imbl 7 | perennial | status | test |
|---|---|---|---|---|---|
hashset::Iter<'a, A> (Item &A) |
Iterator, ExactSize, Fused | adds Clone | as im plus Clone | same | tests/compat_hashset.rs::iter_type |
impl Clone for hashset::Iter |
absent | present | provided (01 "imbl additions kept") | added (imbl API) | tests/compat_hashset.rs::iter_impl_clone |
hashset::ConsumingIter<A> (Item A) |
Iterator, ExactSize, Fused | adds Clone (7.0.2) | as im plus Clone | same | tests/compat_hashset.rs::consuming_iter_type |
impl Clone for hashset::ConsumingIter |
absent | present | provided (01 "imbl additions kept") | added (imbl API) | tests/compat_hashset.rs::consuming_iter_impl_clone |
Trait implementations
| item | im 15.1 | imbl 7 | perennial | status | test |
|---|---|---|---|---|---|
impl Clone |
O(1) | as im | as im | same | tests/compat_hashset.rs::impl_clone |
impl Default |
as im | as im | same | tests/compat_hashset.rs::impl_default |
|
impl Debug |
{a, b, ...} in iteration order; bound A: Hash + Eq + Debug, S: BuildHasher |
bound A: Debug |
format as im; bound loosened to imbl's A: Debug (01:loose-bounds) |
same | tests/differential/hashset.rs |
impl PartialEq (same S) |
content equality | as im | as im | same | tests/differential/hashset.rs |
impl PartialEq<GenericHashSet<A, S2, P2>> |
absent | present | provided (01 "imbl additions kept") | added (imbl API) | tests/compat_hashset.rs::impl_partial_eq_other_hasher |
impl Eq |
as im | as im | same | tests/compat_hashset.rs::impl_eq |
|
impl PartialOrd |
lexicographic over iteration order | removed | kept; compares sorted contents | differs: order-independent comparison (01:ord) | tests/compat_hashset.rs::impl_partial_ord |
impl Ord |
as PartialOrd |
removed | kept; compares sorted contents | differs: order-independent comparison (01:ord) | tests/compat_hashset.rs::impl_ord |
impl Hash |
elements in iteration order; equal sets can hash differently | removed | kept; order-independent | differs: consistent with Eq (01:hash) |
tests/compat_hashset.rs::impl_hash |
impl Add for HashSet<A, S> |
union | as im | as im | same | tests/compat_hashset.rs::impl_add |
impl Add for &HashSet<A, S> |
union | as im | as im | same | tests/compat_hashset.rs::impl_add_ref |
impl Mul for HashSet<A, S> |
intersection | as im | as im | same | tests/compat_hashset.rs::impl_mul |
impl Mul for &HashSet<A, S> |
intersection | as im | as im | same | tests/compat_hashset.rs::impl_mul_ref |
impl Sum |
union of all | as im | as im | same | tests/compat_hashset.rs::impl_sum |
impl Extend<R> (A: From<R>) |
converts each item | as im | as im | same | tests/compat_hashset.rs::impl_extend |
impl FromIterator<RA> (A: From<RA>) |
last equal item kept | as im | as im | same | tests/compat_hashset.rs::impl_from_iterator |
impl IntoIterator for HashSet |
Item A |
as im | as im | same | tests/compat_hashset.rs::impl_into_iterator |
impl IntoIterator for &HashSet |
Item &A |
as im | as im | same | tests/compat_hashset.rs::impl_into_iterator_ref |
impl From<Vec<A>> |
as im | as im | same | tests/compat_hashset.rs::impl_from_vec |
|
impl From<&Vec<A>> |
as im | as im | same | tests/compat_hashset.rs::impl_from_vec_ref |
|
impl From<&[A]> |
as im | as im | same | tests/compat_hashset.rs::impl_from_slice |
|
impl From<&BTreeSet<A>> |
by reference only | as im | as im | same | tests/compat_hashset.rs::impl_from_btree_set_ref |
impl From<BTreeSet<A>> (by value) |
absent | implied by the spec's wording | provided alongside the by-reference form (01:btreeset-by-value) | added (imbl API) | tests/compat_hashset.rs::impl_from_btree_set |
impl From<std::collections::HashSet<A>> |
as im | as im | same | tests/compat_hashset.rs::impl_from_std_hash_set |
|
impl From<&std::collections::HashSet<A>> |
as im | as im | same | tests/compat_hashset.rs::impl_from_std_hash_set_ref |
|
impl From<Vector<A>> |
added in im 15.1.0 | as im | as im | same | tests/compat_hashset_convert.rs::impl_from_vector |
impl From<&Vector<A>> |
added in im 15.1.0 | as im | as im | same | tests/compat_hashset_convert.rs::impl_from_vector_ref |
impl From<OrdSet<A>> |
as im | as im | same | tests/compat_hashset_convert.rs::impl_from_ord_set |
|
impl From<&OrdSet<A>> |
as im | as im | same | tests/compat_hashset_convert.rs::impl_from_ord_set_ref |
|
impl From<&HashSet<&A, SA>> for HashSet<OA, SB> |
owning copy via ToOwned |
as im | as im | same | tests/compat_hashset.rs::impl_from_set_of_refs |
impl From<[A; N]> |
absent | present | provided (01 "imbl additions kept") | added (imbl API) | tests/compat_hashset.rs::impl_from_array |
impl Serialize (feature serde) |
as a sequence | as im | as im | same | tests/compat_hashset_features.rs::impl_serialize |
impl Deserialize (feature serde) |
from a sequence; duplicates collapse | as im | as im | same | tests/compat_hashset_features.rs::impl_deserialize |
impl arbitrary::Arbitrary<'a> (feature arbitrary) |
yes | yes | yes | same | tests/compat_hashset_features.rs::impl_arbitrary |
impl quickcheck::Arbitrary (feature quickcheck) |
im only | yes | both crates (01:features) | same | tests/compat_hashset_features.rs::impl_quickcheck_arbitrary |
impl bincode::Encode / Decode (feature bincode) |
absent | yes | not provided | not provided: imbl-only, not in im's API; not in 0.1 (01:imbl-only) | — |
auto traits Send / Sync |
im-rc neither; im when A is |
as im | perennial-rc neither; perennial when A is |
same | tests/compat_hashset.rs::auto_traits |