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

CountAsync

Consumes an async cursor one awaited step at a time and counts its items. Stops at first EOF or error, destroys discarded owned items normally, and adds no intermediate collection. Task/callback/source costs remain explicit. Count overflow uses ordinary checked arithmetic. A nonterminating source never produces a final count without cancellation or source failure.

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.

CountAsync

pub async fn CountAsync<T, E, I>(mut Cursor: I, Token: CancellationToken) -> Task<Result<usize, E>>
    where T: Movable where E: Movable where I: TypedAsyncIterator<T, E>, Movable

Consumes an async cursor one awaited step at a time and counts its items. Stops at first EOF or error, destroys discarded owned items normally, and adds no intermediate collection. Task/callback/source costs remain explicit. Count overflow uses ordinary checked arithmetic. A nonterminating source never produces a final count without cancellation or source failure. T: Exact Movable item category. E: Movable source error preserved by ownership. I: Movable structural cursor returning the exact typed step task. Cursor: Owned traversal state; explicitly move a named noncopy cursor. Token: Owned cancellation observation copied into each awaited step. Return: Task yielding checked count or the first exact source error. Warning: Stored views/borrowed inputs retain ordinary origin/suspension rules.

CountAsync

pub fn CountAsync<T, E, I>(mut Cursor: I) -> Task<Result<usize, E>>
    where T: Movable where E: Movable where I: TypedAsyncIterator<T, E>, Movable

Supplies the omitted arguments to CountAsync. Note: Defaults: Token = CancellationToken(). T: Same generic argument and constraints as the full operation. E: Same generic argument and constraints as the full operation. I: Same generic argument and constraints as the full operation. Cursor: Same input, ownership and lifetime contract as the full operation. Return: Exact full-operation result; no additional async frame is created.

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