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

Segments

Traverses exact separator-delimited text as borrowed UTF-8 views.

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.text

import std.text;

Public declaration contracts and authored examples. A page can document several related symbols. Implementation bodies are excluded.

Split

pub fn Split(Text: str, Separator: str) -> TextSegments

Traverses exact separator-delimited text as borrowed UTF-8 views. Text: Valid UTF-8 source whose backing owner outlives traversal and items. Separator: Exact ordinal UTF-8 separator; empty yields the whole input once. Return: Allocation-free cursor preserving leading, repeated and trailing empty fields. Warning: Items retain no owner; moving, destroying or mutating the backing owner invalidates them.

Example

module example.borrowed_text_segments;
from std.text import Split, Lines;
fn Main() -> i32 {
    var Cursor = Split("λ::path::", "::");
    switch Cursor.Next() {
        case .Some { Value = Item } => { if Item != "λ" { return 1; } }
        case .None => return 2;
    }
    var Remaining = Cursor.CreateIterator();
    switch Remaining.Next() {
        case .Some { Value = Item } => { if Item != "path" { return 3; } }
        case .None => return 4;
    }
    switch Remaining.Next() {
        case .Some { Value = Item } => { if Item != "" { return 5; } }
        case .None => return 6;
    }
    if Remaining.Next() is .Some { Value = _ } { return 7; }
    var Count = 0;
    for Item in Lines("one\r\n\r\ntwo\n") {
        Count += 1;
    }
    if Count != 3 { return 8; }
    return 0;
}

Lines

pub fn Lines(Text: str) -> TextSegments

Traverses borrowed lines with CR, LF and CRLF terminators removed. Text: Valid UTF-8 source whose owner survives all borrowed items. Return: Allocation-free cursor; empty input has no lines and a terminal separator adds no line. Warning: Empty interior lines are preserved; no owner retention or locale conversion occurs.

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