Skip to content

Instantly share code, notes, and snippets.

Created July 12, 2015 09:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/d0ff1de8b6fc15ef1bb6 to your computer and use it in GitHub Desktop.
Save anonymous/d0ff1de8b6fc15ef1bb6 to your computer and use it in GitHub Desktop.
Shared via Rust Playground
#![feature(const_fn)]
#[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"),
}
}
@jonas-schievink
Copy link

Just for reference, this errors like this on the current (2018-01-25) nightly:

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