summaryrefslogtreecommitdiffstats
path: root/tests/ui/bare-fn-implements-fn-mut.rs
blob: dfead48893e550075917b09e25806ca949d5b3db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// run-pass

use std::ops::FnMut;

fn call_f<F:FnMut()>(mut f: F) {
    f();
}

fn f() {
    println!("hello");
}

fn call_g<G:FnMut(String,String) -> String>(mut g: G, x: String, y: String)
          -> String {
    g(x, y)
}

fn g(mut x: String, y: String) -> String {
    x.push_str(&y);
    x
}

fn main() {
    call_f(f);
    assert_eq!(call_g(g, "foo".to_string(), "bar".to_string()),
               "foobar");
}