Skip to content

Instantly share code, notes, and snippets.

@mgsloan
Created September 18, 2017 08:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgsloan/f728ae5bb502518c242972b35c136f63 to your computer and use it in GitHub Desktop.
Save mgsloan/f728ae5bb502518c242972b35c136f63 to your computer and use it in GitHub Desktop.
fn main() {
let mut x = 1;
wat(|i| { x += i; return x; });
println!("{}", x);
}
fn wat<F>(f: F) -> u32 where F: FnMut(u32) -> u32 {
foo(f)
}
fn foo<F>(mut f: F) -> u32 where F: FnMut(u32) -> u32 {
f(1) + f(2)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment