---
source: https://iinventedlight.com/library/notes/rust-display.md
title: "fmt::Display: how a Rust type prints with {}"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "MIT OR Apache-2.0 (Rust Standard Library); MIT OR Apache-2.0 (Rust By Example); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: Rust Standard Library, std::fmt; Rust By Example, Display. MIT OR Apache-2.0 (https://raw.githubusercontent.com/rust-lang/rust/master/COPYRIGHT). Copyright the Rust Project Developers. MIT OR Apache-2.0 (https://raw.githubusercontent.com/rust-lang/rust-by-example/master/LICENSE-MIT). Copyright the Rust Project Developers."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-23
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-23
as_of: 2026-11-23
confidence: medium
untested: "Not reproduced (2026-11-23). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-systems: rust-display"
tags: [rust, display, fmt, formatting, traits]
client: Librarian
sources:
  - id: S1
    title: "std::fmt"
    publisher: Rust Standard Library
    url: https://doc.rust-lang.org/std/fmt/index.html
    accessed: 2026-11-23
    license: "MIT OR Apache-2.0"
  - id: S2
    title: "Display"
    publisher: Rust By Example
    url: https://doc.rust-lang.org/rust-by-example/hello/print/print_display.html
    accessed: 2026-11-23
    license: "MIT OR Apache-2.0"
---
# fmt::Display: how a Rust type prints with {}
**Answer:** The fmt module provides runtime support for the format! family of macros. To use the {} marker, implement the Display trait. The format string must be a string literal so the compiler can check it.

## format! and Display

Runtime support for the format! syntax extension lives in this module.

The macro writes formatted arguments into strings at runtime.

Calling to_string uses the Display formatting trait.

The format string has to be a string literal. A variable is not accepted, so the compiler can check the string.

## Implementing the trait

Debug output is often not compact or clean, so customizing the appearance is useful.

Implement fmt::Display yourself when you want the {} print marker to look the way you need.

The trait's fmt method must use a specific signature.

## See also

- [rust-from-into](https://iinventedlight.com/library/notes/rust-from-into/)
- [rust-macros](https://iinventedlight.com/library/notes/rust-macros/)

## Claims

- id: C1
  claim: std::fmt supports the format! macro at runtime.
  source: S1
  evidence: "runtime support for the format! syntax extension"

- id: C2
  claim: The format string must be a string literal.
  source: S1
  evidence: "this to be a string literal"

- id: C3
  claim: Implement Display to customize {} output.
  source: S2
  evidence: "manually implementing fmt::Display"

- id: C4
  claim: Display uses the {} print marker.
  source: S2
  evidence: "uses the {} print marker"

## Sources

- [S1] std::fmt. Rust Standard Library. https://doc.rust-lang.org/std/fmt/index.html . License: MIT OR Apache-2.0. Accessed 2026-11-23.

- [S2] Display. Rust By Example. https://doc.rust-lang.org/rust-by-example/hello/print/print_display.html . License: MIT OR Apache-2.0. Accessed 2026-11-23.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Rust Standard Library, std::fmt; Rust By Example, Display. MIT OR Apache-2.0 (https://raw.githubusercontent.com/rust-lang/rust/master/COPYRIGHT). Copyright the Rust Project Developers. MIT OR Apache-2.0 (https://raw.githubusercontent.com/rust-lang/rust-by-example/master/LICENSE-MIT). Copyright the Rust Project Developers. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
