std/prelude
Imported into every program automatically (--no-prelude turns it off): the Error interface, Unit, and the error types that ? and .context() build. It also imports std/string's ASCII helpers, which is why those need no import.
API reference
Error
pub interface ErrorThe structural error interface. Any type with message(self: &Self): string satisfies it, so a fn can return Result<T, Heap<Error>> and ? boxes whatever error a callee produced (a struct, an enum, or a plain string, which arrives as a ErrorMessage). The message is the one thing every error owes its reader; the concrete type is still there behind the box for a caller that wants to look.
ErrorContext
pub struct ErrorContextWhat r.context("reading config") wraps an error in: the note, then the cause it was raised for, so the message reads outermost first ("reading config: not found: x.toml"). The cause is any boxed Error, so a chain nests as deep as the call stack that annotated it.
Fields: note: string, cause: Heap<Error>.
ErrorContext.message
fn ErrorContext.message(self: &ErrorContext): stringThe note, a colon, and the cause's own message.
ErrorMessage
pub struct ErrorMessageA string error boxed as an Error: what ? makes of a Result<T, string> in a fn that returns Result<T, Heap<Error>>.
Fields: text: string.
ErrorMessage.message
fn ErrorMessage.message(self: &ErrorMessage): stringThe string the error was raised with.
Unit
pub struct UnitThe single success value for operations that return no data. Use Result<Unit, E> for fallible commands; void is a function return type, not a value that can inhabit Result.