Skip to content

Instantly share code, notes, and snippets.

@bstrie
Created October 12, 2012 23:49
Show Gist options
  • Save bstrie/3882357 to your computer and use it in GitHub Desktop.
Save bstrie/3882357 to your computer and use it in GitHub Desktop.
fn mk_appender(suffix: ~str) -> @fn(~str) -> ~str {
return @fn(s: ~str) -> ~str { s + suffix }; // error: mismatched types: expected `fn@(~str) -> ~str` but found `@fn&(~str) -> ~str` (expected fn but found @-ptr)
}
fn main() {
let shout = mk_appender(~"!");
io::println(shout(~"hey ho, let's go"));
}
fn mk_appender(suffix: ~str) -> fn@(~str) -> ~str {
return fn@(s: ~str) -> ~str { s + suffix };
}
fn main() {
let shout = mk_appender(~"!");
io::println(shout(~"hey ho, let's go"));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment