2 #![allow(unused_variables)]
3 /* Any copyright is dedicated to the Public Domain.
4 * http://creativecommons.org/publicdomain/zero/1.0/ */
7 where F : FnOnce(String) -> String
9 println!("{}", f("Fred".to_string()))
12 fn call_a_thunk<F>(f: F) where F: FnOnce() {
16 fn call_this<F>(f: F) where F: FnOnce(&str) + Send {
20 fn call_bare(f: fn(&str)) {
24 fn call_bare_again(f: extern "Rust" fn(&str)) {
31 let greeting = "Hello ".to_string();
33 format!("{}{}", greeting, s)
36 let greeting = "Goodbye ".to_string();
37 call_it(|s| format!("{}{}", greeting, s));
39 let greeting = "How's life, ".to_string();
40 call_it(|s: String| -> String {
41 format!("{}{}", greeting, s)
46 call_a_thunk(|| println!("Hello world!"));
48 call_this(|s| println!("{}", s));