1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
use std::fmt::Display; use std::path::{self, Path, PathBuf}; pub trait DisplayAsDisplay { fn as_display(&self) -> Self; } impl<T: Display> DisplayAsDisplay for &T { fn as_display(&self) -> Self { self } } pub trait PathAsDisplay { fn as_display(&self) -> path::Display<'_>; } impl PathAsDisplay for Path { fn as_display(&self) -> path::Display<'_> { self.display() } } impl PathAsDisplay for PathBuf { fn as_display(&self) -> path::Display<'_> { self.display() } }