base library

Re-export of the Result type and related features from the 'rust_core' package.

Classes

Err<S, F extends Object>
Error Result.
Ok<S, F extends Object>
Ok Result.
Result<S, F extends Object>
Result is used for propagating errors and represents the sum type of Ok and Err.

Extensions

FlattenExtension on Result<Result<S, F>, F>
FlattenFutureExtension on FutureResult<Result<S, F>, F>
FutureIterableFutureResultExtension on Future<Iterable<FutureResult<S, F>>>
FutureIterableResultExtension on Future<Iterable<Result<S, F>>>
FutureResultExtension on FutureResult<S, F>
FutureResult represents an asynchronous Result. And as such, inherits all of Results methods.
FutureResultNullExtension on Future<Result<S?, F>>
FutureResultOptionExtension on Future<Result<Option<S?>, F>>
InfallibleErrExtension on Result<Never, F>
InfallibleFutureErrExtension on FutureResult<Never, F>
InfallibleFutureOkExtension on FutureResult<S, Never>
InfallibleOkExtension on Result<S, Never>
IterableFutureResultExtension on Iterable<FutureResult<S, F>>
IterableResultExtension on Iterable<Result<S, F>>
NullResultExtension on Result<S, F>?
RecordFunctionToResult10 on (Result<A, Z> Function(), Result<B, Z> Function(), Result<C, Z> Function(), Result<D, Z> Function(), Result<E, Z> Function(), Result<F, Z> Function(), Result<G, Z> Function(), Result<H, Z> Function(), Result<I, Z> Function(), Result<J, Z> Function())
RecordFunctionToResult2 on (Result<A, Z> Function(), Result<B, Z> Function())
RecordFunctionToResult3 on (Result<A, Z> Function(), Result<B, Z> Function(), Result<C, Z> Function())
RecordFunctionToResult4 on (Result<A, Z> Function(), Result<B, Z> Function(), Result<C, Z> Function(), Result<D, Z> Function())
RecordFunctionToResult5 on (Result<A, Z> Function(), Result<B, Z> Function(), Result<C, Z> Function(), Result<D, Z> Function(), Result<E, Z> Function())
RecordFunctionToResult6 on (Result<A, Z> Function(), Result<B, Z> Function(), Result<C, Z> Function(), Result<D, Z> Function(), Result<E, Z> Function(), Result<F, Z> Function())
RecordFunctionToResult7 on (Result<A, Z> Function(), Result<B, Z> Function(), Result<C, Z> Function(), Result<D, Z> Function(), Result<E, Z> Function(), Result<F, Z> Function(), Result<G, Z> Function())
RecordFunctionToResult8 on (Result<A, Z> Function(), Result<B, Z> Function(), Result<C, Z> Function(), Result<D, Z> Function(), Result<E, Z> Function(), Result<F, Z> Function(), Result<G, Z> Function(), Result<H, Z> Function())
RecordFunctionToResult9 on (Result<A, Z> Function(), Result<B, Z> Function(), Result<C, Z> Function(), Result<D, Z> Function(), Result<E, Z> Function(), Result<F, Z> Function(), Result<G, Z> Function(), Result<H, Z> Function(), Result<I, Z> Function())
RecordToResult10 on (Result<A, Z>, Result<B, Z>, Result<C, Z>, Result<D, Z>, Result<E, Z>, Result<F, Z>, Result<G, Z>, Result<H, Z>, Result<I, Z>, Result<J, Z>)
RecordToResult2 on (Result<A, Z>, Result<B, Z>)
RecordToResult3 on (Result<A, Z>, Result<B, Z>, Result<C, Z>)
RecordToResult4 on (Result<A, Z>, Result<B, Z>, Result<C, Z>, Result<D, Z>)
RecordToResult5 on (Result<A, Z>, Result<B, Z>, Result<C, Z>, Result<D, Z>, Result<E, Z>)
RecordToResult6 on (Result<A, Z>, Result<B, Z>, Result<C, Z>, Result<D, Z>, Result<E, Z>, Result<F, Z>)
RecordToResult7 on (Result<A, Z>, Result<B, Z>, Result<C, Z>, Result<D, Z>, Result<E, Z>, Result<F, Z>, Result<G, Z>)
RecordToResult8 on (Result<A, Z>, Result<B, Z>, Result<C, Z>, Result<D, Z>, Result<E, Z>, Result<F, Z>, Result<G, Z>, Result<H, Z>)
RecordToResult9 on (Result<A, Z>, Result<B, Z>, Result<C, Z>, Result<D, Z>, Result<E, Z>, Result<F, Z>, Result<G, Z>, Result<H, Z>, Result<I, Z>)
ResultFutureToFutureResultExtension on Result<Future<S>, F>
ResultNullExtension on Result<S?, F>
ResultOptionExtension on Result<Option<S?>, F>
ResultToFutureResultExtension on Result<S, F>
ToErrExtension on E
ToOkExtension on S

Functions

guard<S>(S func()) Result<S, Object>
Executes the function in a protected context. func is called inside a try catch block. If the result does not catch, then return value func returned inside an Ok. If func throws, then the thrown value is returned inside an Err.
guardAsync<S>(Future<S> func()) FutureResult<S, Object>
Async version of guard
guardAsyncResult<S>(Future<Result<S, Object>> func()) FutureResult<S, Object>
Async version of guardResult
guardResult<S>(Result<S, Object> func()) Result<S, Object>
Result unwrapping version of guard. Where func returns an Result, but can still throw.
identity<T>(T x) → T
The identity function. While it might seem strange to have a function that just returns back the input, there are some interesting uses.
panic([String? msg]) → Never
Shorthand for
unreachable([String msg = "This code should be unreachable."]) → Never
Shorthand for

Typedefs

FutureResult<S, F extends Object> = Future<Result<S, F>>
FutureResult represents an asynchronous Result. And as such, inherits all of Results methods.
Infallible = Never
The error type for errors that can never happen

Exceptions / Errors

Panic
As with Error, Panic represents a state that should never happen and thus is not expected to be catch. This is closely tied to the unwrap method of both Option and Result types.
Unreachable
Indicates unreachable code. This is useful any time that the compiler can’t determine that some code is unreachable. For example: