Skip to content

Commit

Permalink
Resolve the std/hashbrown conflict situation
Browse files Browse the repository at this point in the history
Big diff, but it’s mostly just whitespace changes; ignore whitespace and
it’s much smaller, though still not as tiny as it could potentially be.

Essentially, this just duplicates everything for the hashbrown variant.

It’d be possible to use generic associated types to achieve this without
the duplication, but that depends on currently-unstable features, and is
probably slightly more painful to use anyway. I’ll keep the approach in
mind for a possible version 2, but for now this is the pragmatic route.
  • Loading branch information
chris-morgan committed Feb 22, 2022
1 parent e04b8b4 commit 40e60ce
Show file tree
Hide file tree
Showing 5 changed files with 568 additions and 568 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ being bigger than I’d earlier intended.

- Fixed the broken `Extend` implementation added in 1.0.0-beta.1.

- Split the hashbrown implementation into a new module, `hashbrown`:
std and hashbrown can now coexist completely peacefully,
with `anymap::Map` being powered by `std::collections::hash_map`,
and `anymap::hashbrown::Map` being powered by `hashbrown::hash_map`.
The `raw_hash_map` alias, provided in 1.0.0-beta.1 because of the ambiguity
of what backed `anymap::Map`, is removed as superfluous and useless.
`RawMap` remains, despite not being *required*, as an ergonomic improvement.
With this, we’re back to proper completely additive Cargo features.

# 1.0.0-beta.1 (2022-01-25)

- Removed `anymap::any::Any` in favour of just plain `core::any::Any`, since its
Expand Down
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ categories = ["rust-patterns", "data-structures", "no-std"]
license = "BlueOak-1.0.0 OR MIT OR Apache-2.0"
include = ["/README.md", "/COPYING", "/CHANGELOG.md", "/src"]

[package.metadata.docs.rs]
all-features = true

[features]
default = ["std"]
std = []
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,20 @@ assert_eq!(&*data.get::<Foo>().unwrap().str, "foot");

## Cargo features/dependencies/usage

Typical Cargo.toml usage:
Typical Cargo.toml usage, providing `anymap::AnyMap` *et al.* backed by `std::collections::HashMap`:

```toml
[dependencies]
anymap = "1.0.0-beta.1"
```

No-std usage, using `alloc` and the [hashbrown](https://rust-lang.github.io/hashbrown) crate instead of `std::collections::HashMap`:
No-std usage, providing `anymap::hashbrown::AnyMap` *et al.* (note the different path, required because Cargo features are additive) backed by `alloc` and the [hashbrown](https://rust-lang.github.io/hashbrown) crate:

```toml
[dependencies]
anymap = { version = "1.0.0-beta.1", default-features = false, features = ["hashbrown"] }
```

The `std` feature is enabled by default. The `hashbrown` feature overrides it. At least one of the two must be enabled.

**On stability:** hashbrown is still pre-1.0.0 and experiencing breaking changes. Because it’s useful for a small fraction of users, I am retaining it, but with *different compatibility guarantees to the typical SemVer ones*. Where possible, I will just widen the range for new releases of hashbrown, but if an incompatible change occurs, I may drop support for older versions of hashbrown with a bump to the *minor* part of the anymap version number (e.g. 1.1.0, 1.2.0). Iff you’re using this feature, this is cause to *consider* using a tilde requirement like `"~1.0"` (or spell it out as `>=1, <1.1`).

## Unsafe code in this library
Expand Down
Loading

0 comments on commit 40e60ce

Please sign in to comment.