custom_display/
custom_display.rs1use std::fmt;
2
3use fmt_ext::{display::*, DisplayExt};
4
5struct ExternCrateType(i32);
7
8struct ExternCrateTypeDisplay;
10
11impl CustomDisplay for ExternCrateTypeDisplay {
13 type Target = ExternCrateType;
14
15 fn fmt_target(target: &Self::Target, f: &mut fmt::Formatter<'_>) -> fmt::Result {
16 write!(f, "Extern type has a value - {}!", target.0)
17 }
18}
19
20impl AttachDisplay<ExternCrateTypeDisplay> for ExternCrateType {}
22
23fn main() {
25 let foo = ExternCrateType(42);
26 println!("{}", foo.display());
27}