Implement the Index and IndexMut traits for Table

master
Philipp Oppermann 8 years ago
parent 62d655fbdd
commit 2b7fa410fb

@ -1,6 +1,21 @@
use core::ops::{Index, IndexMut};
use memory::paging::entry::*; use memory::paging::entry::*;
use memory::paging::ENTRY_COUNT; use memory::paging::ENTRY_COUNT;
pub struct Table { pub struct Table {
entries: [Entry; ENTRY_COUNT], entries: [Entry; ENTRY_COUNT],
} }
impl Index<usize> for Table {
type Output = Entry;
fn index(&self, index: usize) -> &Entry {
&self.entries[index]
}
}
impl IndexMut<usize> for Table {
fn index_mut(&mut self, index: usize) -> &mut Entry {
&mut self.entries[index]
}
}

Loading…
Cancel
Save