Skip to content

Commit 2d3bd56

Browse files
authored
Merge pull request #490 from Wasabi375/zst_hash
Ensure that Page actually implements Hash
2 parents 24691eb + b0843da commit 2d3bd56

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/structures/paging/page.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@ pub trait PageSize: Copy + Eq + PartialOrd + Ord + Sealed {
2323
pub trait NotGiantPageSize: PageSize {}
2424

2525
/// A standard 4KiB page.
26-
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
26+
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
2727
pub enum Size4KiB {}
2828

2929
/// A “huge” 2MiB page.
30-
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
30+
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
3131
pub enum Size2MiB {}
3232

3333
/// A “giant” 1GiB page.
3434
///
3535
/// (Only available on newer x86_64 CPUs.)
36-
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
36+
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
3737
pub enum Size1GiB {}
3838

3939
impl PageSize for Size4KiB {
@@ -429,6 +429,15 @@ impl fmt::Display for AddressNotAligned {
429429
mod tests {
430430
use super::*;
431431

432+
fn test_is_hash<T: core::hash::Hash>() {}
433+
434+
#[test]
435+
pub fn test_page_is_hash() {
436+
test_is_hash::<Page<Size4KiB>>();
437+
test_is_hash::<Page<Size2MiB>>();
438+
test_is_hash::<Page<Size1GiB>>();
439+
}
440+
432441
#[test]
433442
pub fn test_page_ranges() {
434443
let page_size = Size4KiB::SIZE;

0 commit comments

Comments
 (0)