Skip to content

Commit

Permalink
Add constant assertions to check size of a region
Browse files Browse the repository at this point in the history
  • Loading branch information
aumetra committed May 8, 2024
1 parent 305b42c commit 383092d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/std/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ pub struct Region<O: Ownership> {
_marker: PhantomData<O>,
}

const _: () = {
assert!(mem::size_of::<Region<Borrowed>>() == 12);
assert!(mem::size_of::<Region<Owned>>() == 12);
};

impl Region<Borrowed> {
pub fn from_slice(slice: &[u8]) -> Self {
unsafe { Self::from_parts(slice.as_ptr(), slice.len(), slice.len()) }
Expand Down

0 comments on commit 383092d

Please sign in to comment.