public bool IsOkGets a value indicating whether this result is in the Ok state.
All Types / Ferrous.Results
public readonly struct Result<T, TError> : IEquatable<Result<T, TError>>, IResultValue
Represents either success (Ok) or failure (Err) without heap allocations or exceptions. Equivalent to Rust's Result<T, E>.
TTErrorpublic bool IsOkGets a value indicating whether this result is in the Ok state.
public bool IsErrGets a value indicating whether this result is in the Err state.
public bool IsUninitializedGets a value indicating whether this struct was default-initialized without calling Ok or Err.
public static Result<T, TError> Ok(T value)Creates a successful Result<T, TError> containing value.
public static Result<T, TError> Err(TError error)Creates a failed Result<T, TError> containing error.
public bool TryGetOk([MaybeNullWhen(false)] out T value)Attempts to extract the Ok value without throwing.
public bool TryGetErr([MaybeNullWhen(false)] out TError error)Attempts to extract the Err value without throwing.
public T Unwrap()Returns the contained Ok value, throwing InvalidOperationException if Err or uninitialized.
public T Expect(string message)Returns the contained Ok value, throwing InvalidOperationException with message if Err or uninitialized.
public TError UnwrapErr()Returns the contained Err value, throwing InvalidOperationException if Ok or uninitialized.
public TError ExpectErr(string message)Returns the contained Err value, throwing InvalidOperationException with message if Ok or uninitialized.
public T UnwrapOr(T defaultValue)Returns the contained Ok value or defaultValue if Err.
public T UnwrapOrElse(Func<TError, T> fallback)Returns the contained Ok value or computes a fallback from the error if Err.
public Result<TResult, TError> Map<TResult>(Func<T, TResult> selector)Maps a Result<T, TError> to Result<TResult, TError> by applying selector to an Ok value.
public Result<T, TNewError> MapErr<TNewError>(Func<TError, TNewError> selector)Maps a Result<T, TError> to Result<T, TNewError> by applying selector to an Err value.
public Result<TResult, TError> AndThen<TResult>(Func<T, Result<TResult, TError>> binder)Calls binder if the result is Ok; otherwise propagates the Err value.
public Result<T, TNewError> OrElse<TNewError>(Func<TError, Result<T, TNewError>> recovery)Calls recovery if the result is Err; otherwise propagates the Ok value.
public TResult Match<TResult>(Func<T, TResult> onOk, Func<TError, TResult> onErr)Exhaustively matches both Ok and Err branches, returning a value.
public void Match(Action<T> onOk, Action<TError> onErr)Exhaustively matches both Ok and Err branches for side effects.
public Option<T> OkOption()Converts the Ok value into an Option<T>, discarding any error.
public Option<TError> ErrOption()Converts the Err value into an Option<TError>, discarding any success value.
public bool Equals(Result<T, TError> other)public override bool Equals(object? obj)public override int GetHashCode()public override string ToString()