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

TextSegments

Owns allocation-free traversal state for borrowed fields or lines.

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.

TextSegments

pub final class TextSegments

Owns allocation-free traversal state for borrowed fields or lines.

Each yielded str borrows the original backing storage. Copying traversal state retains no owner. Split search is ordinal with O(n*m) worst-case work; line scanning visits bytes once. All returned slice endpoints are UTF-8 boundaries.

TextSegments.CreateIterator

pub readonly fn CreateIterator() -> TextSegments

Creates an independent cursor at the current traversal position. Return: Copy of traversal state borrowing the same source and separator storage. Warning: Advancing either cursor does not extend backing storage lifetime.

TextSegments.Next

pub fn Next() -> str?

Advances once and borrows the next field or unterminated line content. Return: Next borrowed str, including admitted empty items, or none after exhaustion. Warning: Backing source and separator storage must remain live and unchanged.

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