Skip to content

Instantly share code, notes, and snippets.

@nikomatsakis
Created March 15, 2012 21:06
Show Gist options
  • Save nikomatsakis/2046946 to your computer and use it in GitHub Desktop.
Save nikomatsakis/2046946 to your computer and use it in GitHub Desktop.
#[non_copyable]
enum one_shot<A,T> = fn~(A) -> T;
fn execute(-f: one_shot<A>, a: A) -> T { (*f)(a) }
fn mk_one_shot_adder(-v1: ~int) -> one_shot<int,int> {
let v1 = ~some(move v1); // this "move" is not yet legal syntax
ret one_shot(fn~[move v1](v2: int) -> int {
let x = none;
x <-> v1;
ret *option::get(x) + v2;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment