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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//! Traits that provide a custom [Display].
//!
//! # Example
//!
//! The example below shows how implement custom display formatting for an external type that does
//! not implement [Display].
//!
//! ```
//! use std::fmt;
//!
//! use fmt_ext::{display::*, DisplayExt};
//!
//! // Oops, this type does not implement `Display`...
//! struct ExternCrateType(i32);
//!
//! // Create a type that will implement custom display...
//! struct ExternCrateTypeDisplay;
//!
//! // Implement custom display...
//! impl CustomDisplay for ExternCrateTypeDisplay {
//! type Target = ExternCrateType;
//!
//! fn fmt_target(target: &Self::Target, f: &mut fmt::Formatter<'_>) -> fmt::Result {
//! write!(f, "Extern type has a value - {}!", target.0)
//! }
//! }
//!
//! // Attach custom display implementation to the target type...
//! impl AttachDisplay<ExternCrateTypeDisplay> for ExternCrateType {}
//!
//! // Look! We have just call `display` method on the target type...
//! let foo = ExternCrateType(42);
//! println!("{}", foo.display());
//! ```
//!
//! [Display]: core::fmt::Display
use fmt;
/// A marker that helps compiler find the [CustomDisplay] implementation.
/// A trait that proxying a custom [Display] for a target type.
///
/// [Display]: fmt::Display