use iof::{impl_read_one_from_for_from_str, impl_write_into_for_display, show}; use std::{fmt::Display, str::FromStr}; struct Wrapper(T); impl Display for Wrapper { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "{}", self.0) } } impl FromStr for Wrapper { type Err = ::Err; fn from_str(s: &str) -> Result { Ok(Wrapper(s.parse()?)) } } impl_write_into_for_display!(Wrapper); impl_write_into_for_display!(Wrapper<&str>); impl_read_one_from_for_from_str!(Wrapper); impl_read_one_from_for_from_str!(Wrapper); #[test] fn show() { show!(Wrapper(42)); show!(Wrapper("Hello, World!")); }