From 0874625269cc99e0115197370748ad0fba0ce6ca Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Thu, 13 Apr 2017 18:37:03 +0200 Subject: [PATCH] Add methods to retrieve a (mutual) reference to the next table --- src/memory/paging/table.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/memory/paging/table.rs b/src/memory/paging/table.rs index eb20de8..e5a4f14 100644 --- a/src/memory/paging/table.rs +++ b/src/memory/paging/table.rs @@ -24,6 +24,16 @@ impl Table { None } } + + pub fn next_table(&self, index: usize) -> Option<&Table> { + self.next_table_address(index) + .map(|address| unsafe { &*(address as *const _) }) + } + + pub fn next_table_mut(&mut self, index: usize) -> Option<&mut Table> { + self.next_table_address(index) + .map(|address| unsafe { &mut *(address as *mut _) }) + } } impl Index for Table {