convert<TTarget> method

ParseResult<TTarget> convert<TTarget>(
  1. TTarget projection(
    1. T
    )
)

Converts this result to a new target type, either by executing the given projection for a success result, or propagating the exception provider for failure.

  • projection: The projection to apply for the value of this result, if it's a success result.

Returns: A ParseResult for the target type, either with a value obtained by applying the specified projection to the value in this result, or with the same error as this result.

Implementation

ParseResult<TTarget> convert<TTarget>(TTarget Function(T) projection) {
  Preconditions.checkNotNull(projection, 'projection');
  return success
      ? ParseResult.forValue<TTarget>(projection(value))
      : ParseResult<TTarget>._error(_errorProvider, _continueAfterErrorWithMultipleFormats);
}