rust-lang / rust-lang/rfcs

Improve associated type ergonomics

Open
#585 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

T-lang
Dominant language
Markdown
Stars
6.6k
Forks
1.7k
Avg merge
16h 14m
Merged PRs (30d)
1

Description

While we have a shorthand notation Iterator<Item = MyType> for specifying an associated type, it's still more verbose than input types. It may be worth adding support for positional specification of associated types, so that Iterator<MyType> works. There are at least two difficulties/drawbacks:

  1. This should be done in a way that still allows for new, defaulted input types to be added to a trait without breaking existing code.
  2. This might make the order of items within a trait significant, which has no precedent elsewhere in the language.

It's possible for a design to avoid both pitfalls, but the complexity may not be worth it.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with issue #585 and review the examples for positional associated-type syntax, including Iterator<Item = MyType> and Iterator<MyType>. Evaluate whether a proposal can preserve compatibility when defaulted input types are added and avoid making trait item order significant. Done means a resolved design, or a documented conclusion that the added complexity is not worthwhile.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.