Skip to content

Instantly share code, notes, and snippets.

@bblum
Last active December 18, 2015 03:38
Show Gist options
  • Select an option

  • Save bblum/5719126 to your computer and use it in GitHub Desktop.

Select an option

Save bblum/5719126 to your computer and use it in GitHub Desktop.
returning a stack closure
fn foo<'a>(blk: &fn(bar: &'a fn() -> &'a fn())) {
let x = 5;
let bar: &fn() = || { io::println(fmt!("%d", x)); };
do blk || { bar };
}
fn main() {
do foo |bar| { bar()(); }
}
@nikomatsakis
Copy link

fn foo<'a>(blk: fn(bar: fn:'a() -> fn:'a())) {
    let x = 5;
    let bar = || {...};
    blk(|| bar);
}

fn main() {
    do foo |bar| { bar()(); }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment