Skip to content

Instantly share code, notes, and snippets.

@det
Created October 17, 2014 00:28
Show Gist options
  • Save det/0c3f22cdd03de1633fa0 to your computer and use it in GitHub Desktop.
Save det/0c3f22cdd03de1633fa0 to your computer and use it in GitHub Desktop.
#![feature(overloaded_calls)]
use std::ops::Fn;
struct Closure
{
x: uint
}
impl Fn<(uint,), ()> for Closure
{
extern "rust-call" fn call(&self, (y,): (uint,)) -> ()
{
println!("{} {}", self.x, y);
}
}
fn main()
{
let f = Closure{x: 10u};
f(12u);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment