pointer-value-pair 0.1.0

A pair of a pointer and a small integer packed into a pointer-sized object
Documentation
  • Coverage
  • 66.67%
    2 out of 3 items documented0 out of 0 items with examples
  • Size
  • Source code size: 9.68 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.74 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • ennis/pointer-value-pair
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • ennis

Pointer-and-value wrapper type for Rust

This crate provides the PointerAndValue type, a wrapper over a raw *const T pointer that also packs a small integer value in the alignment bits, with the guarantee that mem::size_of::<PointerAndValue<T>>() == mem::size_of::<*const T>().

It is inspired by llvm::PointerIntPair from LLVM, and TfPointerAndBits from USD.

It also provides Cow, which is similar to std::borrow::Cow but stores either &'a T or Box<T>, and is guaranteed to be the same size as *const T.

TODOs and limitations

  • This currently does not work with pointers to zero-sized types because mem::align_of returns a minimum alignment of 1.
  • Support dynamically-sized types