2018-08-30 12:18:55 +00:00
|
|
|
//@ run-pass
|
2013-01-10 22:15:17 +00:00
|
|
|
fn example_err(prog: &str, arg: &str) {
|
2013-09-25 05:16:43 +00:00
|
|
|
println!("{}: {}", prog, arg)
|
2013-01-10 22:15:17 +00:00
|
|
|
}
|
|
|
|
|
2015-01-02 22:32:54 +00:00
|
|
|
fn exit<F>(print: F, prog: &str, arg: &str) where F: FnOnce(&str, &str) {
|
2013-01-10 22:15:17 +00:00
|
|
|
print(prog, arg);
|
|
|
|
}
|
|
|
|
|
2015-01-02 22:32:54 +00:00
|
|
|
struct X<F> where F: FnOnce(&str, &str) {
|
|
|
|
err: F,
|
2013-01-10 22:15:17 +00:00
|
|
|
}
|
|
|
|
|
2015-01-02 22:32:54 +00:00
|
|
|
impl<F> X<F> where F: FnOnce(&str, &str) {
|
2014-02-21 23:41:51 +00:00
|
|
|
pub fn boom(self) {
|
2013-01-10 22:15:17 +00:00
|
|
|
exit(self.err, "prog", "arg");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-02 03:43:17 +00:00
|
|
|
pub fn main(){
|
2014-02-21 23:41:51 +00:00
|
|
|
let val = X {
|
2013-01-10 22:15:17 +00:00
|
|
|
err: example_err,
|
|
|
|
};
|
|
|
|
val.boom();
|
|
|
|
}
|