rust/tests/ui/issues/issue-16668.rs

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

21 lines
489 B
Rust
Raw Normal View History

//@ check-pass
#![allow(dead_code)]
2014-10-25 22:07:41 +00:00
struct Parser<'a, I, O> {
2019-05-28 18:46:13 +00:00
parse: Box<dyn FnMut(I) -> Result<O, String> + 'a>
2014-10-25 22:07:41 +00:00
}
impl<'a, I: 'a, O: 'a> Parser<'a, I, O> {
fn compose<K: 'a>(mut self, mut rhs: Parser<'a, O, K>) -> Parser<'a, I, K> {
2014-10-25 22:07:41 +00:00
Parser {
parse: Box::new(move |x: I| {
match (self.parse)(x) {
Ok(r) => (rhs.parse)(r),
2014-10-25 22:07:41 +00:00
Err(e) => Err(e)
}
})
2014-10-25 22:07:41 +00:00
}
}
}
fn main() {}