Use new Unique API (#346)

Change Unique to use `new_unchecked`. Fixes #345.
This commit is contained in:
Tim Crawford
2017-08-05 00:47:15 -04:00
committed by Philipp Oppermann
parent e54cfa4378
commit 2ebd4ed954
4 changed files with 6 additions and 6 deletions

View File

@@ -247,7 +247,7 @@ pub fn print_something() {
let mut writer = Writer { let mut writer = Writer {
column_position: 0, column_position: 0,
color_code: ColorCode::new(Color::LightGreen, Color::Black), 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'); 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 { pub static WRITER: Writer = Writer {
column_position: 0, column_position: 0,
color_code: ColorCode::new(Color::LightGreen, Color::Black), 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<Writer> = Mutex::new(Writer { pub static WRITER: Mutex<Writer> = Mutex::new(Writer {
column_position: 0, column_position: 0,
color_code: ColorCode::new(Color::LightGreen, Color::Black), 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. [Mutex::new] is a const function, too, so it can be used in statics.

View File

@@ -659,7 +659,7 @@ Because the `ActivePageTable` owns the unique recursive mapped P4 table, there m
impl ActivePageTable { impl ActivePageTable {
pub unsafe fn new() -> ActivePageTable { pub unsafe fn new() -> ActivePageTable {
ActivePageTable { ActivePageTable {
p4: Unique::new(table::P4), p4: Unique::new_unchecked(table::P4),
} }
} }
} }

View File

@@ -19,7 +19,7 @@ pub struct Mapper {
impl Mapper { impl Mapper {
pub unsafe fn new() -> Mapper { pub unsafe fn new() -> Mapper {
Mapper { p4: Unique::new(table::P4) } Mapper { p4: Unique::new_unchecked(table::P4) }
} }
pub fn p4(&self) -> &Table<Level4> { pub fn p4(&self) -> &Table<Level4> {

View File

@@ -18,7 +18,7 @@ const BUFFER_WIDTH: usize = 80;
pub static WRITER: Mutex<Writer> = Mutex::new(Writer { pub static WRITER: Mutex<Writer> = Mutex::new(Writer {
column_position: 0, column_position: 0,
color_code: ColorCode::new(Color::LightGreen, Color::Black), 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 { macro_rules! println {