Under heavy development. This site describes the intended 1.0 language. Current features and performance vary. Development status
Sn50SnThe SnAPI programming language
0.2.0 Preview 1 · Frozen documentation

Formattable

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

Sn is under heavy development. Reference extracted from this release’s bundled standard library. Public API examples are not an exhaustive compatibility test. Read the matching release guide for tested workflows and limitations. 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