1 // check-pass
2
3 pub(crate) trait Parser: Sized {
4 type Output;
parse(&mut self, _input: &str) -> Result<(), ()>5 fn parse(&mut self, _input: &str) -> Result<(), ()> {
6 loop {}
7 }
map<F, B>(self, _f: F) -> Map<Self, F> where F: FnMut(Self::Output) -> B,8 fn map<F, B>(self, _f: F) -> Map<Self, F>
9 where
10 F: FnMut(Self::Output) -> B,
11 {
12 todo!()
13 }
14 }
15
16 pub(crate) struct Chainl1<P, Op>(P, Op);
17 impl<P, Op> Parser for Chainl1<P, Op>
18 where
19 P: Parser,
20 Op: Parser,
21 Op::Output: FnOnce(P::Output, P::Output) -> P::Output,
22 {
23 type Output = P::Output;
24 }
chainl1<P, Op>(_parser: P, _op: Op) -> Chainl1<P, Op> where P: Parser, Op: Parser, Op::Output: FnOnce(P::Output, P::Output) -> P::Output,25 pub(crate) fn chainl1<P, Op>(_parser: P, _op: Op) -> Chainl1<P, Op>
26 where
27 P: Parser,
28 Op: Parser,
29 Op::Output: FnOnce(P::Output, P::Output) -> P::Output,
30 {
31 loop {}
32 }
33
34 pub(crate) struct Map<P, F>(P, F);
35 impl<A, B, P, F> Parser for Map<P, F>
36 where
37 P: Parser<Output = A>,
38 F: FnMut(A) -> B,
39 {
40 type Output = B;
41 }
42
43 impl Parser for u32 {
44 type Output = ();
45 }
46
chainl1_error_consume()47 pub fn chainl1_error_consume() {
48 fn first<T, U>(t: T, _: U) -> T {
49 t
50 }
51 let _ = chainl1(1, 1.map(|_| first)).parse("");
52 }
53
main()54 fn main() {}
55