rust-lang / rust-lang/rfcs

Add more functionality to where clause

Open
#2,715 10 comments 14 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

The where clause is compile-time check, it's a great idea. but I think we can make it even more great by add some more functionality to it.

  1. range check: require port is constexpr implicitly
fn foo(port: usize)
    where   port <= 65535,
            port > 1000,
            port in 1000..65536 // or this one, much better
{}
  1. make it general purpose
let foo = 1..500 where _ % 4 == 0 // something like this ( _ maybe better with it )
let foo = 1..100 where it % 2 == 0 //ah much better

Motivation
In 1, it will improving some performent and much easier to optimize code, not letting code jump around
In 2, just let where everywhere, I think people will love 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 #2715 and review its existing discussion, focusing on the proposed range checks and general-purpose where expressions. Determine whether the scope and syntax can be narrowed into a concrete RFC; done requires an agreed design and clear acceptance through the RFC process.

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.