2019-07-26 21:54:25 +00:00
|
|
|
//@ run-pass
|
|
|
|
|
2015-01-12 15:27:25 +00:00
|
|
|
fn call_f<F:FnMut()>(mut f: F) {
|
2014-07-24 02:57:30 +00:00
|
|
|
f();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn f() {
|
|
|
|
println!("hello");
|
|
|
|
}
|
|
|
|
|
2015-01-12 15:27:25 +00:00
|
|
|
fn call_g<G:FnMut(String,String) -> String>(mut g: G, x: String, y: String)
|
2014-07-24 02:57:30 +00:00
|
|
|
-> String {
|
|
|
|
g(x, y)
|
|
|
|
}
|
|
|
|
|
2014-10-15 06:05:01 +00:00
|
|
|
fn g(mut x: String, y: String) -> String {
|
2015-02-02 02:53:25 +00:00
|
|
|
x.push_str(&y);
|
2014-10-15 06:05:01 +00:00
|
|
|
x
|
2014-07-24 02:57:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
call_f(f);
|
2015-02-02 02:53:25 +00:00
|
|
|
assert_eq!(call_g(g, "foo".to_string(), "bar".to_string()),
|
2014-07-24 02:57:30 +00:00
|
|
|
"foobar");
|
|
|
|
}
|