@@ -68,6 +68,17 @@ public static class Result
6868 /// <returns>The value encapsulated by <see cref="Result{T}"/>.</returns>
6969 public static Result < T > FromValue < T > ( T value ) => new ( value ) ;
7070
71+ /// <summary>
72+ /// Creates a new instance of <see cref="Result{T}"/> from the specified value.
73+ /// </summary>
74+ /// <typeparam name="T">The type of the value.</typeparam>
75+ /// <typeparam name="TError">The type of the error code. Default value must represent the successful result.</typeparam>
76+ /// <param name="value">The value to be placed to the container.</param>
77+ /// <returns>The value encapsulated by <see cref="Result{T, TError}"/>.</returns>
78+ public static Result < T , TError > FromValue < T , TError > ( T value )
79+ where TError : struct , Enum
80+ => new ( value ) ;
81+
7182 /// <summary>
7283 /// Creates a new instance of <see cref="Result{T}"/> from the specified exception.
7384 /// </summary>
@@ -76,6 +87,17 @@ public static class Result
7687 /// <returns>The exception encapsulated by <see cref="Result{T}"/>.</returns>
7788 public static Result < T > FromException < T > ( Exception e ) => new ( e ) ;
7889
90+ /// <summary>
91+ /// Creates a new instance of <see cref="Result{T, TError}"/> from the specified exception.
92+ /// </summary>
93+ /// <typeparam name="T">The type of the value.</typeparam>
94+ /// <typeparam name="TError">The type of the error code. Default value must represent the successful result.</typeparam>
95+ /// <param name="e">The error to be placed to the container.</param>
96+ /// <returns>The exception encapsulated by <see cref="Result{T}"/>.</returns>
97+ public static Result < T , TError > FromError < T , TError > ( TError e )
98+ where TError : struct , Enum
99+ => new ( e ) ;
100+
79101 /// <summary>
80102 /// If successful result is present, apply the provided mapping function hiding any exception
81103 /// caused by the converter.
0 commit comments