kvarn::prelude::internals::prelude::utils::prelude

Module fmt

1.0.0 · source
Expand description

Utilities for formatting and printing Strings.

This module contains the runtime support for the format! syntax extension. This macro is implemented in the compiler to emit calls to this module in order to format arguments at runtime into strings.

§Usage

The format! macro is intended to be familiar to those coming from C’s printf/fprintf functions or Python’s str.format function.

Some examples of the format! extension are:

format!("Hello");                 // => "Hello"
format!("Hello, {}!", "world");   // => "Hello, world!"
format!("The number is {}", 1);   // => "The number is 1"
format!("{:?}", (3, 4));          // => "(3, 4)"
format!("{value}", value=4);      // => "4"
let people = "Rustaceans";
format!("Hello {people}!");       // => "Hello Rustaceans!"
format!("{} {}", 1, 2);           // => "1 2"
format!("{:04}", 42);             // => "0042" with leading zeros
format!("{:#?}", (100, 200));     // => "(
                                  //       100,
                                  //       200,
                                  //     )"

F