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