Class ResultTErrorMapExtensions

Namespace
REslava.Result.Extensions
Assembly
REslava.Result.dll

Map overloads for Result<TValue, TError> typed pipelines. Transforms the success value while leaving the error type unchanged.

public static class ResultTErrorMapExtensions
Inheritance
ResultTErrorMapExtensions
Inherited Members

Methods

Map<TIn, TOut, TError>(Result<TIn, TError>, Func<TIn, TOut>)

Transforms the success value of a typed result using the given mapper. If the result is a failure the error is forwarded unchanged.

public static Result<TOut, TError> Map<TIn, TOut, TError>(this Result<TIn, TError> result, Func<TIn, TOut> mapper) where TError : IError

Parameters

result Result<TIn, TError>

The result to transform.

mapper Func<TIn, TOut>

The function applied to the success value.

Returns

Result<TOut, TError>

A new result with the mapped value, or the original failure.

Type Parameters

TIn

The source value type.

TOut

The target value type.

TError

The error type. Must implement IError.

Examples

Result<Order, ValidationError> result = Validate(req);

Result<OrderDto, ValidationError> dto = result.Map(order => new OrderDto(order));