Separate Writer::write_string and fmt::Write::write_str methods

This commit is contained in:
Philipp Oppermann
2018-03-13 21:12:31 +01:00
parent 7a14fe6a90
commit 78bd186003
2 changed files with 18 additions and 16 deletions

View File

@@ -100,6 +100,17 @@ impl Writer {
}
}
/// Writes the given ASCII string to the buffer.
///
/// Wraps lines at `BUFFER_WIDTH`. Supports the `\n` newline character. Does **not**
/// support strings with non-ASCII characters, since they can't be printed in the VGA text
/// mode.
fn write_string(&mut self, s: &str) {
for byte in s.bytes() {
self.write_byte(byte)
}
}
/// Shifts all lines one line up and clears the last row.
fn new_line(&mut self) {
for row in 1..BUFFER_HEIGHT {
@@ -125,15 +136,8 @@ impl Writer {
}
impl fmt::Write for Writer {
/// Writes the given ASCII string to the buffer.
///
/// Wraps lines at `BUFFER_WIDTH`. Supports the `\n` newline character. Does **not**
/// support strings with non-ASCII characters, since they can't be printed in the VGA text
/// mode.
fn write_str(&mut self, s: &str) -> fmt::Result {
for byte in s.bytes() {
self.write_byte(byte)
}
self.write_string(s);
Ok(())
}
}