Skip to content

Add more functionality to where clause #2715

Open
@CGQAQ

Description

@CGQAQ

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions