Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking issue for `const fn` integration with pattern matching #57240

Open
Centril opened this Issue Dec 31, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@Centril
Copy link
Contributor

Centril commented Dec 31, 2018

Sub-tracking issue for rust-lang/rfcs#911.

This issue tracks integration of const fn with pattern matching... For example:

#[derive(PartialEq, Eq)]
struct Foo { f: usize, g: usize }

const fn ZERO(x: usize) -> Foo { Foo { f: x, g: x } }

fn main() {
    let f = Foo { f: 0, g: 1 };
    match f {
        ZERO(22) => println!("hi"),
        _ => println!("1"),
    }
}

This is currently not implemented:

error[E0532]: expected tuple struct/variant, found function `ZERO`
  --> src/main.rs:11:9
   |
11 |         ZERO(22) => println!("hi"),
   |         ^^^^ not a tuple struct/variant

error: aborting due to previous error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.