JohnDoneth / hd44780-driver

Implementation of the embedded-hal traits for the HD44780.
MIT License
37 stars 40 forks source link

Implement core::fmt::Write for HD44780 #6

Closed robinkrahl closed 5 years ago

robinkrahl commented 5 years ago

This patch implements core::fmt::Write for the HD44780 struct. The only method required by Write, write_str, is already implemented in HD44780. Implementing Write provides write_fmt for free, which can be used like the format! macro in the standard library:

lcd.write_fmt(format_args!("Hello, {}!", "world"));
lcd.write_fmt(format_args!("binary: {:b}", 42));

A downside of this change is that write_str now returns a core::fmt::Result.

JohnDoneth commented 5 years ago

Awesome, this was something I wanted to see implemented as well. Thank you for the PR.