Skip to content

Type std returns by receiver type arguments, and fuse Enum.at - #23

Merged
dannote merged 1 commit into
masterfrom
enum-at-and-option-map
Oct 26, 2026
Merged

dannote merged 1 commit into
masterfrom
enum-at-and-option-map

Conversation

@dannote

@dannote dannote commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

Found while collapsing Figler's 52-function optional-attribute chain into one Enum pipeline.

  • Generic std returns. mix rustq.std keeps a method's return type when it depends only on the receiver's own type parameters, and records those parameters in the order the type takes them. Typing binds them to the receiver's type arguments with the new Type.substitute/2. For example, name.as_ref() on an &Option<String> is an Option<&String>. The table grows from 173 entries to 293. A method whose return type uses its own parameters, like [T]::get's I::Output, is still left out.
  • List literals whose items share a type are typed as a list of it.
  • Enum.at on a stage fuses to .nth(index). Before, it was .collect().get(index).cloned() with an untyped collect.
  • A filter over copied tuple items matches each item by reference, as |&(set, field)| set.
  • Enum.count, length, and byte_size stay usize where one is expected, through a shared integer_count/2 helper. Before, they always cast to i64.
  • The hand-written as_ref typing is removed, since the std table now covers it.

mix ci passes with 888 tests. With this branch, Figler's mix ci also passes, clippy included, apart from the dependency check that fails whenever RustQ comes from a local path.

…n a stage

The std method table keeps returns that depend only on the receiver's own
type parameters, with those parameters in order, and Typing substitutes
the receiver's type arguments: as_ref on an &Option<String> is an
Option<&String>. A list literal of one type is a list of it. Enum.at on a
stage is nth, a filter over copied tuples matches by reference, and counts
stay usize where one is expected.
@dannote
dannote merged commit 81d9716 into master Oct 26, 2026
2 checks passed
@dannote dannote mentioned this pull request Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant