Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created January 30, 2023 22:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rust-play/c40682d4d0ee67d970933f63cc1d8615 to your computer and use it in GitHub Desktop.
Save rust-play/c40682d4d0ee67d970933f63cc1d8615 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
pub struct Foo;
fn main() {
let f = Foo;
let x = f.quux::<{
impl Foo {
pub fn quux<const N: usize>(&self) -> usize {
N
}
}
10
}>();
assert_eq!(x, 10);
}
#[allow(dead_code)]
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