From 337799599a6ef284daa818c63f7d6831d6bb1e9a Mon Sep 17 00:00:00 2001 From: Rafal Mielniczuk Date: Sun, 20 Dec 2015 14:37:54 +0000 Subject: [PATCH] Fix HierachicalLevel typo --- posts/2015-12-09-modifying-page-tables.md | 22 +++++++++++----------- src/memory/paging/table.rs | 10 +++++----- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/posts/2015-12-09-modifying-page-tables.md b/posts/2015-12-09-modifying-page-tables.md index f4d3b5c4..1211fc47 100644 --- a/posts/2015-12-09-modifying-page-tables.md +++ b/posts/2015-12-09-modifying-page-tables.md @@ -340,14 +340,14 @@ impl TableLevel for Level1 {} ``` An empty enum has size zero and disappears completely after compiling. Unlike an empty struct, it's not possible to instantiate an empty enum. Since we will use `TableLevel` and `Level4` in exported types, they need to be public as well. -To differentiate the P1 table from the other tables, we introduce a `HierachicalLevel` trait, which is a subtrait of `TableLevel`. But we implement it only for the levels 4, 3, and 2: +To differentiate the P1 table from the other tables, we introduce a `HierarchicalLevel` trait, which is a subtrait of `TableLevel`. But we implement it only for the levels 4, 3, and 2: ```rust -trait HierachicalLevel: TableLevel {} +trait HierarchicalLevel: TableLevel {} -impl HierachicalLevel for Level4 {} -impl HierachicalLevel for Level3 {} -impl HierachicalLevel for Level2 {} +impl HierarchicalLevel for Level4 {} +impl HierarchicalLevel for Level3 {} +impl HierarchicalLevel for Level2 {} ``` Now we add the level parameter to the `Table` type: @@ -374,7 +374,7 @@ impl Table where L: TableLevel pub fn zero(&mut self) {...} } -impl Table where L: HierachicalLevel +impl Table where L: HierarchicalLevel { pub fn next_table(&self, index: usize) -> Option<&Table> {...} @@ -391,22 +391,22 @@ Now the `next_table` methods are only available for P4, P3, and P2 tables. But t For a P4 table we would like to return a `Table`, for a P3 table a `Table`, and for a P2 table a `Table`. So we want to return a table of the _next level_. -We can define the next level by adding an associated type to the `HierachicalLevel` trait: +We can define the next level by adding an associated type to the `HierarchicalLevel` trait: ```rust -trait HierachicalLevel: TableLevel { +trait HierarchicalLevel: TableLevel { type NextLevel: TableLevel; } -impl HierachicalLevel for Level4 { +impl HierarchicalLevel for Level4 { type NextLevel = Level3; } -impl HierachicalLevel for Level3 { +impl HierarchicalLevel for Level3 { type NextLevel = Level2; } -impl HierachicalLevel for Level2 { +impl HierarchicalLevel for Level2 { type NextLevel = Level1; } ``` diff --git a/src/memory/paging/table.rs b/src/memory/paging/table.rs index 158a4b2c..a2cd7a09 100644 --- a/src/memory/paging/table.rs +++ b/src/memory/paging/table.rs @@ -20,7 +20,7 @@ impl Table where L: TableLevel } } -impl Table where L: HierachicalLevel +impl Table where L: HierarchicalLevel { fn next_table_address(&self, index: usize) -> Option { let entry_flags = self[index].flags(); @@ -87,18 +87,18 @@ impl TableLevel for Level3 {} impl TableLevel for Level2 {} impl TableLevel for Level1 {} -trait HierachicalLevel: TableLevel { +trait HierarchicalLevel: TableLevel { type NextLevel: TableLevel; } -impl HierachicalLevel for Level4 { +impl HierarchicalLevel for Level4 { type NextLevel = Level3; } -impl HierachicalLevel for Level3 { +impl HierarchicalLevel for Level3 { type NextLevel = Level2; } -impl HierachicalLevel for Level2 { +impl HierarchicalLevel for Level2 { type NextLevel = Level1; }