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

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

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