Skip to content

Commit 71bf088

Browse files
committed
Update how the Page type works
This removes the workaround we had before min_const_generics was stable. Signed-off-by: Nathaniel McCallum <[email protected]>
1 parent 6bae168 commit 71bf088

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/page.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ use core::ops::{Deref, DerefMut};
88
/// This type is page-aligned and page-sized.
99
#[derive(Copy, Clone)]
1010
#[repr(C, align(4096))]
11-
pub struct Page([[u64; 32]; 16]);
11+
pub struct Page([u8; Self::SIZE]);
1212

1313
#[cfg(feature = "const-default")]
1414
impl const_default::ConstDefault for Page {
15-
const DEFAULT: Self = Self([[0; 32]; 16]);
15+
const DEFAULT: Self = Self::zeroed();
1616
}
1717

1818
impl Default for Page {
@@ -67,13 +67,17 @@ impl BorrowMut<[u8]> for Page {
6767
}
6868

6969
impl Page {
70-
/// Returns the size of the page in bytes
71-
pub const fn size() -> usize {
72-
core::mem::size_of::<Self>()
70+
/// The page size on the platform
71+
pub const SIZE: usize = 4096;
72+
73+
/// Creates a new page from its bytes
74+
#[inline]
75+
pub const fn new(value: [u8; Self::SIZE]) -> Self {
76+
Self(value)
7377
}
7478

7579
/// Returns a Page full of zeroes
7680
pub const fn zeroed() -> Self {
77-
Self([[0; 32]; 16])
81+
Self([0; Self::SIZE])
7882
}
7983
}

0 commit comments

Comments
 (0)