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

ThenResult

Consumes one wrapper and invokes its safe callback only for the selected case.

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

import std.prelude;

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

ThenResult

pub fn ThenResult<T, U, E>(mut Value: Result<T, E>, Mapper: fn(T) -> Result<U, E>) -> Result<U, E>
    where T: Movable where U: Movable where E: Movable

Consumes one wrapper and invokes its safe callback only for the selected case.

Unselected owned payloads transfer without copying. The callback is invoked exactly once for the selected case and never for the other case; callback captures/costs keep their own contract. This helper adds no allocation, synchronization or implicit error propagation. Reference payloads remain aliases. T: Exact movable payload representation. U: Exact movable payload representation. E: Exact movable payload representation. Value: Owned wrapper consumed by this call; explicitly move noncopy named inputs. Mapper: Nonnullable safe callback with exact input/output types. Return: Flattened selected callback result or preserved opposite case.

ThenResult

pub fn ThenResult<T, U, E, C>(mut Value: Result<T, E>, mut Mapper: C) -> Result<U, E>
    where T: Movable where U: Movable where E: Movable where C: UnaryCallable<T, Result<U, E>>, Movable

Consumes one wrapper and invokes its safe callback only for the selected case.

Unselected owned payloads transfer without copying. The callback is invoked exactly once for the selected case and never for the other case; callback captures/costs keep their own contract. This helper adds no allocation, synchronization or implicit error propagation. Reference payloads remain aliases. T: Exact movable payload representation. U: Exact movable payload representation. E: Exact movable payload representation. C: Concrete movable exact safe readonly callback environment. Value: Owned wrapper consumed by this call; explicitly move noncopy named inputs. Mapper: Owned concrete safe callback with exact input/output types. Return: Flattened selected callback result or preserved opposite case.

ThenResult

pub fn ThenResult<U, E>(mut Value: Result<void, E>, Mapper: fn() -> Result<U, E>) -> Result<U, E>
    where U: Movable where E: Movable

Consumes payloadless success and invokes a safe zero-argument callback. U: Movable resulting success representation. E: Movable error representation, transferred without copying. Value: Owned void-success wrapper. Mapper: Nonnullable safe callback invoked only on Ok. Return: Selected flattened result or preserved Err.

ThenResult

pub fn ThenResult<U, E, C>(mut Value: Result<void, E>, mut Mapper: C) -> Result<U, E>
    where U: Movable where E: Movable where C: NullaryCallable<Result<U, E>>, Movable

Consumes void success and invokes an owned safe zero-argument environment. U: Movable resulting success representation. E: Movable preserved error representation. C: Exact movable safe readonly NullaryCallable environment. Value: Owned void-success wrapper consumed by the call. Mapper: Owned environment; invoked only once on success, never on error. Return: Flattened callback result or transferred original error; no helper allocation.

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