Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Unreleased

- Add support for using `AnyDebug` (from Anymore) as the storage type, for better debugging.
This can be enabled through the `anymore` cargo feature.
If this feature is enabled, the MSRV is 1.86 (as that is Anymore's MSRV so it can use trait upcasting)

# 1.0.1 (2024-11-09)

- Suppress future incompatibility lint in CloneToAny impl. Contributed by @swlynch99 — thank you. ([#2](https://github.com/reivilibre/anymap3/pull/2))
Expand Down
7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
[package]
name = "anymap3"
version = "1.0.1"
authors = ["Olivier 'reivilibre' (fork maintainer) <contact@librepush.net>", "Chris Morgan (original author) <rust@chrismorgan.info>"]
authors = [
"Olivier 'reivilibre' (fork maintainer) <contact@librepush.net>",
"Chris Morgan (original author) <rust@chrismorgan.info>",
]
edition = "2018"
rust-version = "1.36"
description = "A safe and convenient store for one value of each type"
Expand All @@ -21,3 +24,5 @@ std = []
[dependencies]
# The hashbrown feature, disabled by default, is exposed under different stability guarantees than the usual SemVer ones: by preference the version range will only be extended, but it may be shrunk in a MINOR release. See README.md.
hashbrown = { version = ">=0.1.1, <0.16", optional = true }
# If this feature is enabled, anymap3's MSRV is the same as Anymore's.
anymore = { version = "1.0.0", optional = true }
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ anymap3 = { version = "1.0.1", default-features = false, features = ["hashbrown"

**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`).

This crate can also be used with `AnyDebug` from the [Anymore](https://docs.rs/anymore/latest/anymore) crate.
This is enabled using the `anymore` cargo feature.
If this feature is enabled, this crate's MSRV is the same as Anymore's.

## Unsafe code in this library

This library uses a fair bit of unsafe code for several reasons:
Expand Down
9 changes: 9 additions & 0 deletions src/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,12 @@ implement!(CloneAny + Send + Sync);
impl_clone!(dyn CloneAny);
impl_clone!(dyn CloneAny + Send);
impl_clone!(dyn CloneAny + Send + Sync);

#[cfg(feature = "anymore")]
use anymore::AnyDebug;
#[cfg(feature = "anymore")]
implement!(AnyDebug);
#[cfg(feature = "anymore")]
implement!(AnyDebug + Send);
#[cfg(feature = "anymore")]
implement!(AnyDebug + Send + Sync);
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,9 @@ fn type_id_hasher() {
unsafe { core::mem::transmute::<TypeId, u128>(type_id) } as u64
);
}
// TODO: As of (presumably) https://github.com/rust-lang/rust/pull/121358, these tests fail
// Presumably, this is an endianness issue - debug printing shows that the bits which are output
// are a subset of the correct bits.
// Pick a variety of types, just to demonstrate it’s all sane. Normal, zero-sized, unsized, &c.
verify_hashing_with(TypeId::of::<usize>());
verify_hashing_with(TypeId::of::<()>());
Expand Down
6 changes: 5 additions & 1 deletion test
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ run_tests() {
cargo $1 test $release --no-default-features # Not very useful without std or hashbrown, but hey, it works! (Doctests emit an error about needing a global allocator, but it exits zero anyway. ¯\_(ツ)_/¯)
cargo $1 test $release --no-default-features --features hashbrown
cargo $1 test $release
cargo $1 test $release --all-features
cargo $1 test $release --features std,hashbrown
done
}

Expand All @@ -20,6 +20,10 @@ run_tests +1.36.0
rm Cargo.lock
run_tests

# We only test anymore on stable, as it has a 1.82 MSRV.
cargo test --features anymore
cargo test --no-default-features --features anymore,hashbrown

cargo clippy
cargo bench
cargo doc