Skip to content

[Repo Assist] Add AsyncSeq.last, item, tryItem#259

Merged
dsyme merged 3 commits intomainfrom
repo-assist/improve-last-item-df3fa74494af1aa5
Mar 1, 2026
Merged

[Repo Assist] Add AsyncSeq.last, item, tryItem#259
dsyme merged 3 commits intomainfrom
repo-assist/improve-last-item-df3fa74494af1aa5

Conversation

@github-actions
Copy link
Contributor

🤖 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

Function Description Mirrors
AsyncSeq.last Returns the last element; raises InvalidOperationException if empty Seq.last
AsyncSeq.item Returns element at specified index; raises ArgumentException if out of bounds Seq.item
AsyncSeq.tryItem Returns element at specified index as option, or None if out of bounds Seq.tryItem

These complete the common positional-access API alongside the existing head, tail, tryFirst, tryLast, lastOrDefault, and firstOrDefault.

Implementation notes

  • last is implemented via tryLast (already existed), raising InvalidOperationException on None — same pattern as head/tryFirst.
  • tryItem traverses the sequence up to the requested index, short-circuiting as soon as possible. Returns None for negative indices.
  • item delegates to tryItem and raises ArgumentException on None.

Test Status

Build succeeded; 267 tests pass (net8.0), including 11 new tests for the three functions.

Generated by Repo Assist

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@afb00b92a9514fee9a14c583f059a03d05738f70

- 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>
@dsyme dsyme marked this pull request as ready for review March 1, 2026 13:30
@dsyme dsyme merged commit f2f8be5 into main Mar 1, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant