Write trait

This commit is contained in:
greg 2019-07-10 02:45:37 -07:00
parent 65c824e104
commit 00e97bbd24

View File

@ -1,4 +1,6 @@
use volatile::Volatile; use volatile::Volatile;
use core::fmt;
use core::fmt::Write;
#[allow(dead_code)] #[allow(dead_code)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
@ -86,13 +88,18 @@ impl Writer {
} }
} }
impl fmt::Write for Writer {
fn write_str(&mut self, s: &str) -> fmt::Result {
self.write_string(s);
Ok(())
}
}
pub fn yolo() { pub fn yolo() {
let mut writer = Writer { let mut writer = Writer {
column_position: 0, color_code: ColorCode::new(Color::Yellow, Color::Black), column_position: 0, color_code: ColorCode::new(Color::Yellow, Color::Black),
buffer: unsafe { &mut *(0xb8000 as *mut Buffer) }, buffer: unsafe { &mut *(0xb8000 as *mut Buffer) },
}; };
writer.write_string("Gamarjoba, munde\n"); write!(writer, "Gamarjoba munde {}", 34);
writer.write_string("Hella bro");
writer.write_string("sore は");
} }