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

IntegerRange

Stores one compiler-constructed fixed-width integer progression.

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

import std.iteration;

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

IntegerRange

pub struct IntegerRange<T>

Stores one compiler-constructed fixed-width integer progression.

Range syntax evaluates start, end, and optional step exactly once and creates this opaque allocation-free value. The compiler preserves signed direction, endpoint inclusion, and no-overflow termination semantics.

T: Fixed-width integer element type selected by the compiler's range expression.

Example

module example.integer_range;
fn Main() -> i32 {
    let Range = 0_i32..=5_i32 by 2_i32;
    var Cursor = Range.CreateIterator();
    var Sum = 0;
    loop {
        switch Cursor.Next() {
            case .Some { Value = Item } => Sum += Item;
            case .None => break;
        }
    }
    return Sum - 6;
}

IntegerRange.CreateIterator

pub readonly fn CreateIterator() -> IntegerRangeIterator<T>

Creates an independent cursor at the progression's first test. Return: Allocation-free cursor borrowing no external owner.

IntegerRangeIterator

pub struct IntegerRangeIterator<T>

Owns traversal state for one fixed-width integer progression.

The opaque cursor is produced only from IntegerRange<T> and cannot expose a wrapping or out-of-range sentinel. T: Fixed-width integer element type of the originating IntegerRange<T> progression.

IntegerRangeIterator.Next

pub fn Next() -> T?

Tests, yields, and advances once without overflowing T. Return: The next progression value or none after endpoint crossing.

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