From 00e97bbd249fbcc999cfd088b37ce17de8de32c3 Mon Sep 17 00:00:00 2001 From: greg Date: Wed, 10 Jul 2019 02:45:37 -0700 Subject: [PATCH] Write trait --- src/vga_buffer.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/vga_buffer.rs b/src/vga_buffer.rs index c34f01c..a6d052e 100644 --- a/src/vga_buffer.rs +++ b/src/vga_buffer.rs @@ -1,4 +1,6 @@ use volatile::Volatile; +use core::fmt; +use core::fmt::Write; #[allow(dead_code)] #[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() { let mut writer = Writer { column_position: 0, color_code: ColorCode::new(Color::Yellow, Color::Black), buffer: unsafe { &mut *(0xb8000 as *mut Buffer) }, }; - writer.write_string("Gamarjoba, munde\n"); - writer.write_string("Hella bro"); - writer.write_string("sore は"); + write!(writer, "Gamarjoba munde {}", 34); }