implemented fmt::Write for Writer
This commit is contained in:
parent
237b99941f
commit
2bd6ba35fc
1 changed files with 10 additions and 1 deletions
|
@ -1,3 +1,4 @@
|
|||
use core::fmt;
|
||||
use volatile::Volatile;
|
||||
|
||||
#[allow(dead_code)]
|
||||
|
@ -61,6 +62,13 @@ pub struct Writer {
|
|||
buffer: &'static mut Buffer,
|
||||
}
|
||||
|
||||
impl fmt::Write for Writer {
|
||||
fn write_str(&mut self, s: &str) -> fmt::Result {
|
||||
self.write_string(s);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Writer {
|
||||
pub fn write_byte(&mut self, byte: u8) {
|
||||
match byte {
|
||||
|
@ -101,6 +109,7 @@ impl Writer {
|
|||
|
||||
// function to test things: to be removed
|
||||
pub fn print_something() {
|
||||
use core::fmt::Write;
|
||||
let mut writer = Writer {
|
||||
column_position: 0,
|
||||
color_code: ColorCode::new(Color::Pink, Color::Black),
|
||||
|
@ -109,5 +118,5 @@ pub fn print_something() {
|
|||
|
||||
writer.write_byte(b'H');
|
||||
writer.write_string("ello ");
|
||||
writer.write_string("Wörld!");
|
||||
write!(writer, "The numbers are {} and {}", 42, 1.0/3.0).unwrap();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue