blob: 7beb91a28d270ee56d0c1b5bf00937ecbfdf9bc2 (
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
|
// run-pass
fn example_err(prog: &str, arg: &str) {
println!("{}: {}", prog, arg)
}
fn exit<F>(print: F, prog: &str, arg: &str) where F: FnOnce(&str, &str) {
print(prog, arg);
}
struct X<F> where F: FnOnce(&str, &str) {
err: F,
}
impl<F> X<F> where F: FnOnce(&str, &str) {
pub fn boom(self) {
exit(self.err, "prog", "arg");
}
}
pub fn main(){
let val = X {
err: example_err,
};
val.boom();
}
|