From 0827c3624623cda343ac48d7131da441f14dcc3b Mon Sep 17 00:00:00 2001 From: Mattias Nordqvist Date: Tue, 17 Sep 2024 13:26:27 +0200 Subject: [PATCH] add new implicit operator --- .../DotNetThoughts.Results/DotNetThoughts.Results.csproj | 2 +- Results/DotNetThoughts.Results/Result.cs | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Results/DotNetThoughts.Results/DotNetThoughts.Results.csproj b/Results/DotNetThoughts.Results/DotNetThoughts.Results.csproj index d5326eb..fd18619 100644 --- a/Results/DotNetThoughts.Results/DotNetThoughts.Results.csproj +++ b/Results/DotNetThoughts.Results/DotNetThoughts.Results.csproj @@ -1,7 +1,7 @@  - 1.5.7 + 1.5.8 True MIT diff --git a/Results/DotNetThoughts.Results/Result.cs b/Results/DotNetThoughts.Results/Result.cs index d9e627b..b26c795 100644 --- a/Results/DotNetThoughts.Results/Result.cs +++ b/Results/DotNetThoughts.Results/Result.cs @@ -40,6 +40,15 @@ public readonly record struct Result [Pure] public static implicit operator Result(Result result) => result.ToUnitResult(); + /// + /// This implicit operator takes a Result of type T and returns a Result of type Unit by throwing away the value, preserving only success or failure, along with errors. + /// This UnitResult is then wrapped in a completed Task. + /// It is the same as calling Task.FromResult(result.ToUnitResult()). + /// + /// + [Pure] + public static implicit operator Task>(Result result) => Task.FromResult(result.ToUnitResult()); + /// /// Creates a successful Result of type T. ///