Skip to content

Commit

Permalink
Fix Exclude & Lead to dispose enumerator
Browse files Browse the repository at this point in the history
This is a squashed merge or PR #673 that closes #649.

It fixes mistakes made in commit "Replace using statements with
declarations" (hash cdc6f76)
as part of PR #622.
  • Loading branch information
Orace authored and atifaziz committed Nov 9, 2019
1 parent 6fc7657 commit 2539d3c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion MoreLinq/Exclude.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static IEnumerable<T> Exclude<T>(this IEnumerable<T> sequence, int startI
{
var index = -1;
var endIndex = startIndex + count;
var iter = sequence.GetEnumerator();
using var iter = sequence.GetEnumerator();
// yield the first part of the sequence
while (iter.MoveNext() && ++index < startIndex)
yield return iter.Current;
Expand Down
2 changes: 1 addition & 1 deletion MoreLinq/Lead.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static IEnumerable<TResult> Lead<TSource, TResult>(this IEnumerable<TSour
return _(); IEnumerable<TResult> _()
{
var leadQueue = new Queue<TSource>(offset);
var iter = source.GetEnumerator();
using var iter = source.GetEnumerator();

bool hasMore;
// first, prefetch and populate the lead queue with the next step of
Expand Down

0 comments on commit 2539d3c

Please sign in to comment.