rust-lang / rust-lang/rfcs

Allow `where` clauses on enum variants

Open
#2,999 8 comments 22 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Described here: https://internals.rust-lang.org/t/pre-rfc-trait-bounds-on-individual-enum-variants/9514

My personal use-case is to add the Sized bound to an enum variant to avoid boxing, eg.

enum Foo<T: ?Sized> {
    Concrete(ConcreteImpl<T>) where T: Sized,
    Upcasted(Box<dyn Impl<T>>),
}

For the moment, I'm forced to always use the boxed representation, even if Foo is never upcasted to a Foo<dyn Bar> and always operates on concrete types.

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 by reading the linked pre-RFC and the enum example in this issue. Determine the intended syntax and semantics for bounds on individual enum variants, including the Sized use case. Done means the proposal is fully specified and its interaction with generic and dynamically sized types is resolved.

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.