Open udoprog opened 4 years ago
This sounds like something that safe transmute might help with if/when that becomes a thing. In the meantime, perhaps the zerocopy crate would work? Although, it looks like zerocopy is more narrowly focused on casting between a T
and a [u8]
, which is probably overly specific for this crate's needs.
Note that there's a note under transmute which covers this. Thanks to ark
from the Rust language Discord (turning a Vec<&T>
into a Vec<Option<&T>>
):
https://doc.rust-lang.org/core/mem/fn.transmute.html#alternatives
If so, the library could currently make use of an assumption that
&mut Vec<AtomicUsize>
can be safely coerced to&mut Vec<usize>
.This is desirable since it would let us use
Vec<T>
more directly in bothBitSet
andAtomicBitSet
, leading to less work, less unsafe, and less code.Note: You can test this by explicitly disabling the
vec-safety
feature in which case we will fall back to using a vector. Otherwise we make use of a wrapper for all vector operations which has a fixed representation#[repr(C)]
, and mimics all the vector APIs we use. This feature currently exists for benchmarks and will most likely be removed in the future.