Skip to content

Commit

Permalink
added Option.ToResult(TError) overload
Browse files Browse the repository at this point in the history
  • Loading branch information
BarionLP committed Nov 29, 2024
1 parent 9195a80 commit 7d7deda
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Ametrin.Optional.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<PropertyGroup>
<PackageId>Ametrin.Optional</PackageId>
<Version>0.1.0</Version>
<Version>0.1.1</Version>
<Authors>Barion</Authors>
<Company>Ametrin Studios</Company>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
Expand Down
4 changes: 4 additions & 0 deletions src/Operations/Conversion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ partial struct Option<TValue>

public Result<TValue> ToResult(Func<Exception> error)
=> _hasValue ? _value : error();

[OverloadResolutionPriority(1)]
public Result<TValue, TError> ToResult<TError>(TError error)
=> _hasValue ? _value : error;
public Result<TValue, TError> ToResult<TError>(Func<TError> error)
=> _hasValue ? _value : error();
}
Expand Down

0 comments on commit 7d7deda

Please sign in to comment.