#[derive(Clone, Default, PartialEq, Debug)]
pub struct ToFmt<T: ?Sized> {
inner: T,
}
impl<T> ToFmt<T> {
pub fn new(inner: T) -> Self {
Self { inner }
}
pub fn into_inner(self) -> T {
self.inner
}
}
impl<T: ?Sized> ToFmt<T> {
pub fn inner(&self) -> &T {
&self.inner
}
pub fn inner_mut(&mut self) -> &mut T {
&mut self.inner
}
}
impl<T: embedded_io::Write + ?Sized> core::fmt::Write for ToFmt<T> {
fn write_str(&mut self, s: &str) -> core::fmt::Result {
self.inner.write_all(s.as_bytes()).or(Err(core::fmt::Error))
}
}