Skip to content

Instantly share code, notes, and snippets.

@Sgeo
Created September 9, 2016 02:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Sgeo/933a70fe9f5c102dc68ee187b1a9c519 to your computer and use it in GitHub Desktop.
Save Sgeo/933a70fe9f5c102dc68ee187b1a9c519 to your computer and use it in GitHub Desktop.
use std::any::TypeId;
use std::any::Any;
fn wrap<F: Fn()+Any>(closure: F) -> extern "C" fn() {
extern "C" fn wrapped<F: Any>() -> () {
println!("Haven't written this yet! TypeId: {:?}", TypeId::of::<F>());
}
println!("Storing closure {:?}", TypeId::of::<F>());
wrapped::<F>
}
fn main() {
wrap(|| println!("Hi"));
wrap(|| println!("Bye"));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment