From: Kit Rhett Aultman Date: Mon, 2 Sep 2024 23:45:48 +0000 (-0400) Subject: console.rs: write entire strings without a loop X-Git-Url: https://git.kitaultman.com/?a=commitdiff_plain;h=a915a2977f20b45de0a115e399113206a258f919;p=riscv_baremetal.git console.rs: write entire strings without a loop The MmioSerialPort already has a write_str() function, so there's no need to loop the bytes. Actually, given that MmioSerialPort also has a fmt::Write trait, it's possible that we don't actually need to implement it for Console at all. --- diff --git a/src/console.rs b/src/console.rs index 3644555..511e1a5 100644 --- a/src/console.rs +++ b/src/console.rs @@ -35,10 +35,7 @@ impl Console { impl core::fmt::Write for Console { fn write_str(&mut self, s: &str) -> core::fmt::Result { - for byte in s.bytes() { - self.serial_port.send(byte); - } - Ok(()) + return self.serial_port.write_str(s); } }