Skip to main content

DisplayAttr

Derive Macro DisplayAttr 

Source
#[derive(DisplayAttr)]
{
    // Attributes available to this derive:
    #[fmt]
    #[fmt_display]
}
Expand description

Derive macro for implementing std::fmt::Display.

§Attributes

  • #[fmt_display("...", args...)] - Format string specifically for Display (highest priority)
  • #[fmt("...", args...)] - Shared format string for both Display and Debug (fallback)

§Example

use format_attr::DisplayAttr;

#[derive(DisplayAttr)]
#[fmt("User: {}", self.name)]
struct User {
    name: String,
}