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

All

Tests whether every cursor item satisfies a safe predicate.

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

import std.iteration;

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

All

pub fn All<T, I>(mut Cursor: I, Predicate: fn(T) -> bool) -> bool
    where T: Copyable
    where I: TypedIterator<T>

Tests whether every cursor item satisfies a safe predicate.

Stops at the first false result; empty input is true. No intermediate allocation occurs. Callback side effects and synchronization are explicit caller contracts; references retain their source's access and invalidation. T: Exact Copyable input item category. I: Structural cursor inferred from Cursor. Cursor: Traversal state; move a non-Copy cursor to transfer ownership. Predicate: Safe callback invoked once per examined item. Return: False at the first mismatch; true after first exhaustion. Warning: Later items are not pulled after a mismatch; backing is not retained.

Example

module example.all_iterator;
from std.iteration import All;
fn Positive(Value: i32&) -> bool { return Value > 0; }
fn Main() -> i32 {
    let Values: i32[3] = [1, 20, 42];
    if !All<i32&>(Values.CreateIterator(), Positive) { return 1; }
    let Mixed: i32[2] = [1, -1];
    if All<i32&>(Mixed.CreateIterator(), Positive) { return 2; }
    let Empty: i32[0] = [];
    if !All<i32&>(Empty.CreateIterator(), Positive) { return 3; }
    return 0;
}

All

pub fn All<T, I>(mut Cursor: I, Predicate: fn(readonly T&) -> bool) -> bool
    where T: Movable where I: TypedIterator<T>

Consumes a cursor with a safe predicate that borrows each exact item.

Owns each optional carrier during callback evaluation, avoiding non-Copy payload copies. Examined non-returned items receive ordinary destruction. Traversal is ordered and synchronous with no intermediate allocation or lock. T: Exact Movable source item type. I: Structural cursor, inferred from Cursor. Cursor: Owned traversal state, consumed through first exhaustion or short circuit. Predicate: Safe readonly observer; backing validity remains its source contract. Return: Short-circuit boolean result; empty input returns true. Warning: Callback cost and reference backing lifetime remain explicit; no implicit ownership retention.

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