Under heavy development. This site describes the intended 1.0 language. Current features and performance vary. Development status
Sn50SnThe SnAPI programming language
Development · Evolving reference

Formattable

Defines the compile-time-only structural contract used by interpolation.

Sn is under heavy development. This reference includes the intended 1.0 design; features may be incomplete in the current compiler. Read the status →

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.

Documentation snapshot: October 24, 2026 About versions ↗
Searching Development · language & standard library