[Repo Assist] Add AsyncSeq.last, item, tryItem#259
Merged
Conversation
- AsyncSeq.last: returns the last element; raises InvalidOperationException if empty, mirroring Seq.last - AsyncSeq.item: returns element at given index; raises ArgumentException if out of bounds, mirroring Seq.item - AsyncSeq.tryItem: returns element at given index as option, or None if out of bounds, mirroring Seq.tryItem 11 new tests; 267 total pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This is an automated pull request from Repo Assist.
Adds three index/last-element combinators that were missing from the API, completing the symmetry with
Seq:Changes
AsyncSeq.lastInvalidOperationExceptionif emptySeq.lastAsyncSeq.itemArgumentExceptionif out of boundsSeq.itemAsyncSeq.tryItemoption, orNoneif out of boundsSeq.tryItemThese complete the common positional-access API alongside the existing
head,tail,tryFirst,tryLast,lastOrDefault, andfirstOrDefault.Implementation notes
lastis implemented viatryLast(already existed), raisingInvalidOperationExceptiononNone— same pattern ashead/tryFirst.tryItemtraverses the sequence up to the requested index, short-circuiting as soon as possible. ReturnsNonefor negative indices.itemdelegates totryItemand raisesArgumentExceptiononNone.Test Status
Build succeeded; 267 tests pass (net8.0), including 11 new tests for the three functions.