---
title: "Compatibility: HashSet · perennial"
description: "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,…"
canonical: "https://perennial.avarok.net/docs/compat/hashset/"
lastmod: "2026-12-01T23:57:36Z"
tokens: 6840
---

1. [Docs](https://perennial.avarok.net/docs/)
2. [Compat](https://perennial.avarok.net/docs/compat/)

# Compatibility: HashSet

perennial@0.1.0·Updated 2026-12-01·5 min read·[View as markdown](https://perennial.avarok.net/docs/compat/hashset/index.md)

Spec: `docs/spec/hashset.md`, `docs/spec/set-algebra.md`, `docs/spec/hashing.md`. Legend and `01:` labels: [../COMPAT.md](https://perennial.avarok.net/docs/compat/). `GenericHashSet` rows are in [crate.md](https://perennial.avarok.net/docs/compat/crate/), `HashSetPool` rows in [features.md](https://perennial.avarok.net/docs/compat/features/). `OrdSet: From<HashSet>` rows are in [ordset.md](https://perennial.avarok.net/docs/compat/ordset/).

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`                        |

```json
{
  "@context": "https://schema.org",
  "@graph": [
    {
      "@id": "https://thomaspbraun.com/#person",
      "@type": "Person",
      "name": "Thomas Braun",
      "sameAs": [
        "https://github.com/tbraun96",
        "https://x.com/tbraun96"
      ],
      "url": "https://thomaspbraun.com",
      "worksFor": {
        "@type": "Organization",
        "name": "Avarok",
        "url": "https://avarok.net"
      }
    },
    {
      "@id": "https://perennial.avarok.net/docs/compat/hashset/",
      "@type": "WebPage",
      "author": {
        "@id": "https://thomaspbraun.com/#person"
      },
      "dateModified": "2026-12-01T23:57:36Z",
      "description": "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,…",
      "inLanguage": "en",
      "isPartOf": {
        "@id": "https://perennial.avarok.net/#website",
        "@type": "WebSite",
        "name": "perennial",
        "url": "https://perennial.avarok.net/"
      },
      "name": "Compatibility: HashSet · perennial",
      "url": "https://perennial.avarok.net/docs/compat/hashset/"
    }
  ]
}
```
