Released internment 0.5.2

I just released internment 0.5.2. An interned object is a smart pointer type that ensures that identical objects have identical pointer values, so rather than hashing an object you can hash its pointer, and comparisons for equality reduce to comparison of pointer values.

The most recent feature is that internment now uses std::ptr::NonNull to introduce a niche, so Option<LocalIntern<T>> will occupy the same space as LocalIntern<T>, which is the size of a single pointer (and similarly for ArcIntern). Intern<T> already had this feature because it does not use raw pointers internally (or any unsafe code!) since earlier this year.

Also earlier this year, I have culled a few dependencies, and hid ArcIntern under a feature ("arc"), so you don't have to pay for its dependencies if you don't use threads.

4 Likes

This is a really cool crate!

While browsing I noticed that heap_location is racy, and I would advocate swapping the store with a compare_exchange and using the result regardless of whether it succeeded or not. Right now if two threads call heap_location concurrently they may give different results.

Thanks so much for catching this bug! That was one of the places where I eliminated the use of once_cell. It seemed pretty simple, but obviously I failed to consider the case of a race. Pretty obvious, once you point it out, and a bit embarrassing.

I've just published the crate with the fix.