Skip to content

Commit edf743a

Browse files
committed
Rewrite empty without CE
1 parent 99fe960 commit edf743a

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/FSharp.Control.TaskSeq/TaskSeq.fs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,15 @@ module TaskSeq =
1111
// Just for convenience
1212
module Internal = TaskSeqInternal
1313

14-
let empty<'T> = taskSeq {
15-
for c: 'T in [] do
16-
yield c
17-
}
14+
let empty<'T> =
15+
{ new IAsyncEnumerable<'T> with
16+
member _.GetAsyncEnumerator (_) =
17+
{ new IAsyncEnumerator<'T> with
18+
member _.MoveNextAsync () = ValueTask.FromResult false
19+
member _.get_Current () = invalidOp "The sequence is empty."
20+
member _.DisposeAsync () = ValueTask.CompletedTask
21+
}
22+
}
1823

1924
let isEmpty source = Internal.isEmpty source
2025

0 commit comments

Comments
 (0)