Skip to main content

Mojo module

fmt

Text formatting: traits for writing types as human-readable UTF-8 strings.

The fmt package provides traits that control how types format themselves as text and where that text gets written. The Writable trait describes how a type converts itself to UTF-8 text, while the Writer trait accepts formatted output from writable types. Together, they enable efficient formatting without unnecessary allocations by directly to destinations like files, strings, or network sockets.

Use this package to implement custom text formatting for your types, control output representation, or write formatted data directly to various destinations.

Traitsโ€‹

  • โ€‹Writable: The Writable trait describes how a type is written into a Writer.
  • โ€‹Writer: Describes a type that can be written to by any type that implements the write_to function.

Was this page helpful?