Formattable
Defines the compile-time-only structural contract used by interpolation.
Module std.format
import std.format;Public declaration contracts and authored examples. A page can document several related symbols. Implementation bodies are excluded.
Formattable
pub concept Formattable<Self>Defines the compile-time-only structural contract used by interpolation.
A satisfying type exposes the exact free FormatTo operation below. The compiler selects a normalized witness statically; no concept object, erased descriptor, allocation-failure channel, or runtime dispatch is introduced.
Example
module example.formattable;
from std.format import Formattable;
fn Main() -> i32 {
// Interpolation proves i32 satisfies the imported structural concept.
let Text: str = $"value={42}";
return 0;
}Formattable.FormatTo
requires fn FormatTo(
Value: readonly Self&,
Builder: mut StringBuilder&
) -> void;Appends one borrowed value to the supplied owning builder. Value: Read-only borrow valid for the complete call. Builder: Writable builder borrow receiving bytes in source order. Return: No value; sticky allocation failure remains private builder state.