console.rs: write entire strings without a loop
authorKit Rhett Aultman <kit@kitaultman.com>
Mon, 2 Sep 2024 23:45:48 +0000 (19:45 -0400)
committerKit Rhett Aultman <kit@kitaultman.com>
Mon, 2 Sep 2024 23:45:48 +0000 (19:45 -0400)
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.

src/console.rs

index 3644555f286b6e307726ee71c2b989295e699b8e..511e1a571ce164352b696e60e44e5cd1e4475c90 100644 (file)
@@ -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);
     }
 }