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
445 B
Rust
Raw Normal View History

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