Skip to content

Commit

Permalink
chore: Clearer assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
tesuji committed Sep 8, 2024
1 parent a4be496 commit 410a30e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/internals/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ pub struct BytesAsReparseDataBuffer {
value: Box<[MaybeU8; MAXIMUM_REPARSE_DATA_BUFFER_SIZE as usize]>,
}

// Asserts that pointers of `BytesAsReparseDataBuffer` can be casted to
// `REPARSE_DATA_BUFFER`.
const _: () = {
let a = align_of::<BytesAsReparseDataBuffer>();
let b = align_of::<REPARSE_DATA_BUFFER>();
[(); 1][!((a % b) == 0) as usize]
assert!((a % b) == 0);
};

impl BytesAsReparseDataBuffer {
// MSRV(1.82): Use `Box::new_uninit_slice` instead.
pub fn new() -> Self {
type Raw = [MaybeU8; MAXIMUM_REPARSE_DATA_BUFFER_SIZE as usize];
const LAYOUT: Layout = Layout::new::<Raw>();
Expand Down

0 comments on commit 410a30e

Please sign in to comment.