Draft
Conversation
ax0l0tl
reviewed
Jan 31, 2025
|
|
||
| return await none().ConfigureAwait(false); | ||
| } | ||
|
|
Member
There was a problem hiding this comment.
Is this actually a breaking change? -> GetValueOrDefault...
Member
Author
There was a problem hiding this comment.
You mean the match? In certain cases, as seen in GetValueOrDefault, it breaks the C# type inference.
park-jasper
reviewed
Feb 20, 2025
| return await result.Bind(convert).ConfigureAwait(false); | ||
| } | ||
|
|
||
| public static async Task<Option<T>> OrElse<T>(this Task<Option<T>> option, Option<T> other) |
Member
There was a problem hiding this comment.
This is one I have implemented by hand in some projects as well.
Other names we had in mind were .Chain, so like you are chaining the options and take the first one that contains some, or .FallbackTo but .OrElse also sounds good
| ShouldBeSome42(await none.OrElse(() => Task.FromResult(Some(42)))); | ||
| return; | ||
|
|
||
| void ShouldBeSome42(Option<int> option) => option.Should().BeSome().Subject.Should().Be(42); |
Member
There was a problem hiding this comment.
.BeSome() returns an AndWithConstraint<...>, so you can say
Suggested change
| void ShouldBeSome42(Option<int> option) => option.Should().BeSome().Subject.Should().Be(42); | |
| void ShouldBeSome42(Option<int> option) => option.Should().BeSome().Which.Should().Be(42); |
and use .Which
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.