Skip to content

Commit cafcf4c

Browse files
committed
Reuse ctor
1 parent bd7d90e commit cafcf4c

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/DotNext/Result.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,25 +91,20 @@ public static class Result
9191
/// Initializes a new successful result.
9292
/// </summary>
9393
/// <param name="value">The value to be stored as result.</param>
94-
public Result(T value)
95-
{
96-
this.value = value;
97-
exception = null;
98-
}
94+
public Result(T value) => this.value = value;
9995

10096
/// <summary>
10197
/// Initializes a new unsuccessful result.
10298
/// </summary>
10399
/// <param name="error">The exception representing error. Cannot be <see langword="null"/>.</param>
104100
public Result(Exception error)
101+
: this(ExceptionDispatchInfo.Capture(error))
105102
{
106-
exception = ExceptionDispatchInfo.Capture(error);
107-
Unsafe.SkipInit(out value);
108103
}
109104

110105
private Result(ExceptionDispatchInfo dispatchInfo)
111106
{
112-
value = default!;
107+
Unsafe.SkipInit(out value);
113108
exception = dispatchInfo;
114109
}
115110

0 commit comments

Comments
 (0)