Range / tuple enums
Nobody has claimed this yet.
- Dominant language
- Markdown
- Stars
- 6.6k
- Forks
- 1.7k
- Avg merge
- 16h 14m
- Merged PRs (30d)
- 1
Description
I've been thinking about writing a strict type for a deck of cards in rust (for example), and I've found myself really wanting this feature. The idea is to allow ranges or tuples in the definition of an enum. This would allow Rust to express (easily) larger numbers of variants for enums. This would play nicely with enum refinement typing, as I've read about elsewhere.
enum CardValue(0...13);
// Or
enum CardValue(1,2,3,4,5,6,7,8,9,10,11,12,13);
enum Suit {
Hearts,
Diamonds,
Clubs,
Spades,
}
struct Card {
value: CardValue,
suit: Suit,
}
// Or
struct Card {
value: enum(0...13),
suit: Suit,
}
// Or
struct Card {
value: (0...13),
suit: Suit,
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue provides example enum syntax but names no files, tests, or entry points. Start by evaluating the proposed range and tuple enum forms and their relationship to enum refinement typing; done would require a resolved design rather than an implementation target.
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
- Mostly clear
- Newbie friendliness
- 25/100