rust/tests/ui/fn/issue-3904.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

26 lines
444 B
Rust
Raw Normal View History

// run-pass
2013-01-10 16:15:17 -06:00
fn example_err(prog: &str, arg: &str) {
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) {
pub fn boom(self) {
2013-01-10 16:15:17 -06:00
exit(self.err, "prog", "arg");
}
}
pub fn main(){
let val = X {
2013-01-10 16:15:17 -06:00
err: example_err,
};
val.boom();
}