diff --git a/CHANGELOG.md b/CHANGELOG.md index d031bfd..8803d11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) diff --git a/Cargo.toml b/Cargo.toml index 178d09f..90f5d98 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,10 @@ [package] name = "anymap3" version = "1.0.1" -authors = ["Olivier 'reivilibre' (fork maintainer) ", "Chris Morgan (original author) "] +authors = [ + "Olivier 'reivilibre' (fork maintainer) ", + "Chris Morgan (original author) ", +] edition = "2018" rust-version = "1.36" description = "A safe and convenient store for one value of each type" @@ -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 } diff --git a/README.md b/README.md index 9ecc17d..f80afa8 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/src/any.rs b/src/any.rs index e3db751..26e4dc0 100644 --- a/src/any.rs +++ b/src/any.rs @@ -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); diff --git a/src/lib.rs b/src/lib.rs index 28b9149..06bc78d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -652,6 +652,9 @@ fn type_id_hasher() { unsafe { core::mem::transmute::(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::()); verify_hashing_with(TypeId::of::<()>()); diff --git a/test b/test index 49f9775..52fcb24 100755 --- a/test +++ b/test @@ -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 } @@ -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