You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 both BitSet and AtomicBitSet, 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.
The text was updated successfully, but these errors were encountered:
udoprog
changed the title
Can Vec<T> be safely coerced to Vec<U> if T has identical layout to U?
Can we prove that Vec<T> is safe to coerce into Vec<U> if T has identical layout to U?
Jan 27, 2020
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.
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.The text was updated successfully, but these errors were encountered: