From 2b7fa410fbce36a85c2f6a40741366a5baa5f69a Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Thu, 13 Apr 2017 18:32:00 +0200 Subject: [PATCH] Implement the Index and IndexMut traits for Table --- src/memory/paging/table.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/memory/paging/table.rs b/src/memory/paging/table.rs index a6652b5..4ce7991 100644 --- a/src/memory/paging/table.rs +++ b/src/memory/paging/table.rs @@ -1,6 +1,21 @@ +use core::ops::{Index, IndexMut}; use memory::paging::entry::*; use memory::paging::ENTRY_COUNT; pub struct Table { entries: [Entry; ENTRY_COUNT], } + +impl Index for Table { + type Output = Entry; + + fn index(&self, index: usize) -> &Entry { + &self.entries[index] + } +} + +impl IndexMut for Table { + fn index_mut(&mut self, index: usize) -> &mut Entry { + &mut self.entries[index] + } +}