@@ -9,17 +9,27 @@ module ValueTask =
99 open System.Threading
1010 open System.Threading .Tasks
1111
12- let FromResult < 'T > ( result : 'T ) =
13- ValueTask< 'T>( result)
14-
15- let FromException < 'T > ( e : exn ) =
16- ValueTask< 'T>( Task.FromException< 'T>( e))
12+ /// <summary>Creates a <see cref="ValueTask{TResult}"/> that's completed successfully with the specified result.</summary>
13+ /// <typeparam name="TResult">The type of the result returned by the task.</typeparam>
14+ /// <param name="result">The result to store into the completed task.</param>
15+ /// <returns>The successfully completed task.</returns>
16+ let FromResult < 'TResult > ( result : 'TResult ) = ValueTask< 'TResult> result
17+
18+ /// <summary>Creates a <see cref="ValueTask{TResult}"/> that's completed exceptionally with the specified exception.</summary>
19+ /// <typeparam name="TResult">The type of the result returned by the task.</typeparam>
20+ /// <param name="exception">The exception with which to complete the task.</param>
21+ /// <returns>The faulted task.</returns>
22+ let FromException < 'TResult > ( ``exception`` : exn ) = ValueTask< 'TResult> ( Task.FromException< 'TResult> `` exception `` )
1723
18- let FromCanceled < 'T > ( ct : CancellationToken ) =
19- ValueTask< 'T>( Task.FromCanceled< 'T>( ct))
20-
21- let FromTask < 'T > ( t : Task < 'T >) =
22- ValueTask< 'T>( t)
24+ /// <summary>Creates a <see cref="ValueTask{TResult}"/> that's completed due to cancellation with the specified token.</summary>
25+ /// <typeparam name="TResult">The type of the result returned by the task.</typeparam>
26+ /// <param name="cancellationToken">The token with which to complete the task.</param>
27+ /// <returns>The canceled task.</returns>
28+ let FromCanceled < 'TResult > ( cancellationToken : CancellationToken ) = ValueTask< 'TResult> ( Task.FromCanceled< 'TResult> cancellationToken)
29+
30+ /// <summary>Creates a <see cref="ValueTask{TResult}"/> from a <see cref="Task{TResult}"/>.</summary>
31+ /// <param name="source">Task workflow.</param>
32+ let FromTask < 'TResult > ( source : Task < 'TResult >) = ValueTask< 'TResult> source
2333
2434 /// <summary>Creates a ValueTask workflow from 'source' another, mapping its result with 'f'.</summary>
2535 let map ( f : 'T -> 'U ) ( source : ValueTask < 'T >) : ValueTask < 'U > =
0 commit comments