This review is from Crev, a distributed system for code reviews. To add your review, set up cargo-crev.

The current version of ptr-union is 2.2.2.

1.0.0 (older version) Rating: Positive Thoroughness: High Understanding: High

by cad97 on 2020-02-10

I am the author of this crate. As such, I obviously trust it and believe it is useful. So this review will instead point at the trickiest parts and try to rationalize them.

Don't believe cargo-geiger for this crate. The majority of the API is macro-generated, and cargo-geiger misses unsafe invocations emitted by the complex macro.

This crate makes liberal usage of unreachable_unchecked, but for cases where the case is trivially actually unreachable.

However, using this crate will decrease the required unsafe for your crate, as it gives you alignment-tagged pointer unions for only one line of unsafe per union type. The unsafe burden you take on is to guarantee the alignment required to store the tag within.

Smoke tests are run under miri, but the crate could potentially do with some more examples as well as some more tests to ensure that all of the functionality works as advertised.

I've only put this review as positive rather than strong because of a lack of real-world use. As of yet, the library is just of theoretical use, and has yet to be stress tested for real. has been able to verify that all files in the crate's tarball are in the crate's repository with a git tag matching the version. Please note that this check is still in beta, and absence of this confirmation does not mean that the files don't match.

Crates in the registry are tarball snapshots uploaded by crates' publishers. The registry is not using crates' git repositories, so there is a possibility that published crates have a misleading repository URL, or contain different code from the code in the repository.

To review the actual code of the crate, it's best to use cargo crev open ptr-union. Alternatively, you can download the tarball of ptr-union v2.2.2 or view the source online.