From 2ebd4ed954fc909b0b7295bfb59ac99c7d5bb590 Mon Sep 17 00:00:00 2001 From: Tim Crawford Date: Sat, 5 Aug 2017 00:47:15 -0400 Subject: [PATCH] Use new Unique API (#346) Change Unique to use `new_unchecked`. Fixes #345. --- blog/content/posts/04-printing-to-screen/index.md | 6 +++--- blog/content/posts/06-page-tables/index.md | 2 +- src/memory/paging/mapper.rs | 2 +- src/vga_buffer.rs | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/blog/content/posts/04-printing-to-screen/index.md b/blog/content/posts/04-printing-to-screen/index.md index ccf5d4d8..6433e6c6 100644 --- a/blog/content/posts/04-printing-to-screen/index.md +++ b/blog/content/posts/04-printing-to-screen/index.md @@ -247,7 +247,7 @@ pub fn print_something() { let mut writer = Writer { column_position: 0, color_code: ColorCode::new(Color::LightGreen, Color::Black), - buffer: unsafe { Unique::new(0xb8000 as *mut _) }, + buffer: unsafe { Unique::new_unchecked(0xb8000 as *mut _) }, }; writer.write_byte(b'H'); @@ -431,7 +431,7 @@ To provide a global writer that can used as an interface from other modules, we pub static WRITER: Writer = Writer { column_position: 0, color_code: ColorCode::new(Color::LightGreen, Color::Black), - buffer: unsafe { Unique::new(0xb8000 as *mut _) }, + buffer: unsafe { Unique::new_unchecked(0xb8000 as *mut _) }, }; ``` @@ -479,7 +479,7 @@ use spin::Mutex; pub static WRITER: Mutex = Mutex::new(Writer { column_position: 0, color_code: ColorCode::new(Color::LightGreen, Color::Black), - buffer: unsafe { Unique::new(0xb8000 as *mut _) }, + buffer: unsafe { Unique::new_unchecked(0xb8000 as *mut _) }, }); ``` [Mutex::new] is a const function, too, so it can be used in statics. diff --git a/blog/content/posts/06-page-tables/index.md b/blog/content/posts/06-page-tables/index.md index 8c2e8187..a8247555 100644 --- a/blog/content/posts/06-page-tables/index.md +++ b/blog/content/posts/06-page-tables/index.md @@ -659,7 +659,7 @@ Because the `ActivePageTable` owns the unique recursive mapped P4 table, there m impl ActivePageTable { pub unsafe fn new() -> ActivePageTable { ActivePageTable { - p4: Unique::new(table::P4), + p4: Unique::new_unchecked(table::P4), } } } diff --git a/src/memory/paging/mapper.rs b/src/memory/paging/mapper.rs index 4c5ef311..c46a87cd 100644 --- a/src/memory/paging/mapper.rs +++ b/src/memory/paging/mapper.rs @@ -19,7 +19,7 @@ pub struct Mapper { impl Mapper { pub unsafe fn new() -> Mapper { - Mapper { p4: Unique::new(table::P4) } + Mapper { p4: Unique::new_unchecked(table::P4) } } pub fn p4(&self) -> &Table { diff --git a/src/vga_buffer.rs b/src/vga_buffer.rs index 2a321e61..f3374940 100644 --- a/src/vga_buffer.rs +++ b/src/vga_buffer.rs @@ -18,7 +18,7 @@ const BUFFER_WIDTH: usize = 80; pub static WRITER: Mutex = Mutex::new(Writer { column_position: 0, color_code: ColorCode::new(Color::LightGreen, Color::Black), - buffer: unsafe { Unique::new(0xb8000 as *mut _) }, + buffer: unsafe { Unique::new_unchecked(0xb8000 as *mut _) }, }); macro_rules! println {