rust/src/test/ui/issues/issue-16668.rs

21 lines
486 B
Rust
Raw Normal View History

// compile-pass
#![allow(dead_code)]
2014-10-25 22:07:41 +00:00
struct Parser<'a, I, O> {
parse: Box<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() {}