New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional functional functionality to Result. #2135

Merged
merged 4 commits into from Jun 16, 2017

Conversation

Projects
None yet
2 participants
@jshier
Contributor

jshier commented Jun 4, 2017

This PR adds mapError and flatMapError to transform Result error values; withValue and withError to execute closures with values without transforming; and ifSuccess, ifFailure to execute closures without values. This should cover most all of the Result use cases.

@cnoon

Looks really good overall @jshier...just a few minor comments.

Show outdated Hide outdated Source/Result.swift
Show outdated Hide outdated Source/Result.swift
Show outdated Hide outdated Tests/ResultTests.swift
let result: Result<String> = .failure(ResultError())
// When
let mappedResult = result.flatMapError { try OtherError(error: $0) }

This comment has been minimized.

@cnoon

cnoon Jun 16, 2017

Member

Newline?

@cnoon

cnoon Jun 16, 2017

Member

Newline?

This comment has been minimized.

@jshier

jshier Jun 16, 2017

Contributor

Addressed in 9bf29.

@jshier

jshier Jun 16, 2017

Contributor

Addressed in 9bf29.

// Then
XCTAssertEqual(string, "success")
}

This comment has been minimized.

@cnoon

cnoon Jun 16, 2017

Member

How about: // MARK: - If Success or Failure Tests?

@cnoon

cnoon Jun 16, 2017

Member

How about: // MARK: - If Success or Failure Tests?

This comment has been minimized.

@jshier

jshier Jun 16, 2017

Contributor

Addressed in 9bf29.

@jshier

jshier Jun 16, 2017

Contributor

Addressed in 9bf29.

Show outdated Hide outdated Tests/ResultTests.swift
Show outdated Hide outdated Tests/ResultTests.swift
// Then
XCTAssertEqual(string, "success")
}

This comment has been minimized.

@cnoon

cnoon Jun 16, 2017

Member

// MARK: - Functional Chaining Tests?

@cnoon

cnoon Jun 16, 2017

Member

// MARK: - Functional Chaining Tests?

This comment has been minimized.

@jshier

jshier Jun 16, 2017

Contributor

Addressed in 9bf29.

@jshier

jshier Jun 16, 2017

Contributor

Addressed in 9bf29.

@cnoon cnoon self-assigned this Jun 16, 2017

@cnoon cnoon added the result label Jun 16, 2017

@cnoon cnoon added this to the 4.5.0 milestone Jun 16, 2017

@cnoon

One last comment.

Show outdated Hide outdated Tests/ResultTests.swift
@cnoon

cnoon approved these changes Jun 16, 2017

Looks good! 👍🏼

@cnoon cnoon merged commit fca8178 into master Jun 16, 2017

1 check was pending

continuous-integration/travis-ci/pr The Travis CI build is in progress
Details

@cnoon cnoon deleted the functional-enhancements branch Jun 16, 2017

@groue groue referenced this pull request Oct 2, 2017

Closed

Completing #2135 #2306

1 of 1 task complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment