public ResultOrErrorDetails <TDestination> Map <TDestination>(Func <T, TDestination> mapper) { if (mapper == null) { throw new ArgumentNullException(nameof(mapper)); } if (!_result.IsDefined) { if (typeof(T) == typeof(TDestination)) { //@ return this; } return(ResultOrErrorDetails <TDestination> .FromError(_error.Value)); } var newResult = mapper(_result.Value); if (newResult == null) { throw new ArgumentException($"The provided {nameof(mapper)} returned null, which is not valid"); } if ((typeof(T) == typeof(TDestination)) && newResult.Equals(_result.Value)) { //@ return this; } return(new ResultOrErrorDetails <TDestination>(newResult, _error)); }