Implement fmt::Write trait for Writer

This commit is contained in:
Philipp Oppermann
2015-09-24 18:04:27 +02:00
parent 4668acb09e
commit c547b128e5
2 changed files with 11 additions and 1 deletions

View File

@@ -13,7 +13,7 @@
// limitations under the License.
#![feature(no_std, lang_items)]
#![feature(const_fn, unique)]
#![feature(const_fn, unique, core_str_ext)]
#![no_std]
extern crate rlibc;

View File

@@ -1,4 +1,5 @@
use core::ptr::Unique;
use core::fmt;
use spin::Mutex;
const BUFFER_HEIGHT: usize = 25;
@@ -78,6 +79,15 @@ impl Writer {
}
}
impl fmt::Write for Writer {
fn write_str(&mut self, s: &str) -> ::core::fmt::Result {
for byte in s.bytes() {
self.write_byte(byte)
}
Ok(())
}
}
#[derive(Clone, Copy)]
struct ColorCode(u8);