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
resultResult<TIn, TError>The result to transform.
mapperFunc<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
TInThe source value type.
TOutThe target value type.
TErrorThe error type. Must implement IError.
Examples
Result<Order, ValidationError> result = Validate(req);
Result<OrderDto, ValidationError> dto = result.Map(order => new OrderDto(order));