Skip to content

Instantly share code, notes, and snippets.

Created March 23, 2016 08:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/35c12dedde3ad8c7297c to your computer and use it in GitHub Desktop.
Save anonymous/35c12dedde3ad8c7297c to your computer and use it in GitHub Desktop.
Shared via Rust Playground
#![feature(unboxed_closures, fn_traits)]
fn get_fn_ptr<C: Fn() -> ()>(_: &C) -> extern "rust-call" fn(&C, ()) -> () {
<C as std::ops::Fn<()>>::call
}
fn main() {
println!("{:x}", get_fn_ptr(&||{}) as usize);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment