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

Result

Represents either one successful value or one recoverable error value.

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

import std.prelude;

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

Result

pub enum Result<T, E>

Represents either one successful value or one recoverable error value.

The selected case and payload are stored directly without allocation, hidden exceptions, or implicit error logging.

T: Successful payload type. E: Recoverable error payload type.

Example

module example.result;
from std.io import IoError;
from std.prelude import Result;
fn Select(Succeeded: bool) -> Result<void, IoError> {
    if Succeeded { return .Ok; }
    return .Err { Error = .OutputFailed };
}
fn Main() -> i32 {
    let ResultValue = Select(true);
    switch ResultValue {
        case .Ok => return 0;
        case .Err { Error = _ } => return 1;
    }
}

Result.Ok

Ok;

Stores the successful result payload.

Result.Ok.Value

Value: T;

Owns the successful value.

Result.Err

Err;

Stores the recoverable error payload.

Result.Err.Error

Error: E;

Owns the recoverable error value.

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