-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
struct AlignedVec
: Make generic over alignment (#764)
This makes `AlignedVec` generic over alignments by using a marker `trait AlignedByteChunk` `impl`ed for types with the same alignment and size (e.x. `Align64<[u8; 64]>`. Since `#[repr(align(N))]` is not a const generic, const generics couldn't be used for this, but this works nicely. We check that `mem::size_of::<C>() == mem::align_of::<C>()` in `AlignedVec`'s constructors to ensure `AlignedByteChunk` is `impl`ed on valid types. Thus, I also ensured that the `AlignedVec`s were actually constructed, not transmuted through `unsafe { mem::zeroed() }`.
- Loading branch information
Showing
3 changed files
with
47 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters