Skip to content

Instantly share code, notes, and snippets.

@riking
Forked from rust-play/playground.rs
Last active January 30, 2023 22:05
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 riking/8a5197cc67a6514ac6583c67aae32f4c to your computer and use it in GitHub Desktop.
Save riking/8a5197cc67a6514ac6583c67aae32f4c to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
pub struct Foo;
fn main() {
recheck();
let f = Foo;
let x = f.quux::<{
impl Foo {
pub fn quux<const N: usize>(&self) -> usize {
N
}
}
10
}>();
assert_eq!(x, 10);
}
fn recheck() {
let f = Foo;
assert_eq!(f.quux::<10>(), 10);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment