summaryrefslogtreecommitdiffstats
path: root/tests/ui/issues/issue-16668.rs
blob: 92efb42fe30917b658d01e79aa0ed51bae6d0ef4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// check-pass
#![allow(dead_code)]
struct Parser<'a, I, O> {
    parse: Box<dyn FnMut(I) -> Result<O, String> + 'a>
}

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> {
        Parser {
            parse: Box::new(move |x: I| {
                match (self.parse)(x) {
                    Ok(r) => (rhs.parse)(r),
                    Err(e) => Err(e)
                }
            })
        }
    }
}

fn main() {}