1010
1111//! Helper parser combinators.
1212
13- use std:: ops:: RangeFrom ;
14-
1513use nom:: {
1614 error:: { ErrorKind , ParseError } ,
17- AsChar , Err , IResult , InputIter , InputLength , InputTake ,
18- InputTakeAtPosition , Offset , Parser , Slice ,
15+ AsChar , Err , IResult , Input , Offset , Parser ,
1916} ;
2017
2118/// Applies the given `map` function to the `parser`'s [`IResult`] in case it
@@ -26,13 +23,13 @@ use nom::{
2623/// [`Error`]: nom::Err::Error
2724/// [`Failure`]: nom::Err::Failure
2825/// [`verify()`]: nom::combinator::verify()
29- pub ( crate ) fn map_err < I , O1 , E : ParseError < I > , F , G > (
26+ pub ( crate ) fn map_err < I , F , G > (
3027 mut parser : F ,
3128 mut map : G ,
32- ) -> impl FnMut ( I ) -> IResult < I , O1 , E >
29+ ) -> impl FnMut ( I ) -> IResult < I , F :: Output , F :: Error >
3330where
34- F : Parser < I , O1 , E > ,
35- G : FnMut ( Err < E > ) -> Err < E > ,
31+ F : Parser < I > ,
32+ G : FnMut ( Err < F :: Error > ) -> Err < F :: Error > ,
3633{
3734 move |input : I | parser. parse ( input) . map_err ( & mut map)
3835}
@@ -47,26 +44,19 @@ where
4744/// non-`escapable` `Input` or end of line.
4845///
4946/// [`escaped()`]: nom::bytes::complete::escaped()
50- pub ( crate ) fn escaped0 < ' a , Input , Error , F , G , O1 , O2 > (
47+ pub ( crate ) fn escaped0 < ' a , I , Error , F , G > (
5148 mut normal : F ,
5249 control_char : char ,
5350 mut escapable : G ,
54- ) -> impl FnMut ( Input ) -> IResult < Input , Input , Error >
51+ ) -> impl FnMut ( I ) -> IResult < I , I , Error >
5552where
56- Input : Clone
57- + Offset
58- + InputLength
59- + InputTake
60- + InputTakeAtPosition
61- + Slice < RangeFrom < usize > >
62- + InputIter
63- + ' a ,
64- <Input as InputIter >:: Item : AsChar ,
65- F : Parser < Input , O1 , Error > ,
66- G : Parser < Input , O2 , Error > ,
67- Error : ParseError < Input > ,
53+ I : Clone + Offset + Input + ' a ,
54+ <I as Input >:: Item : AsChar ,
55+ F : Parser < I , Error = Error > ,
56+ G : Parser < I , Error = Error > ,
57+ Error : ParseError < I > ,
6858{
69- move |input : Input | {
59+ move |input : I | {
7060 let mut i = input. clone ( ) ;
7161 let mut consumed_nothing = false ;
7262
7666 match ( normal. parse ( i. clone ( ) ) , consumed_nothing) {
7767 ( Ok ( ( i2, _) ) , false ) => {
7868 if i2. input_len ( ) == 0 {
79- return Ok ( ( input. slice ( input. input_len ( ) .. ) , input) ) ;
69+ return Ok ( ( input. take_from ( input. input_len ( ) ) , input) ) ;
8070 }
8171 if i2. input_len ( ) == current_len {
8272 consumed_nothing = true ;
@@ -102,11 +92,11 @@ where
10292 ErrorKind :: Escaped ,
10393 ) ) ) ;
10494 }
105- match escapable. parse ( i. slice ( next.. ) ) {
95+ match escapable. parse ( i. take_from ( next) ) {
10696 Ok ( ( i2, _) ) => {
10797 if i2. input_len ( ) == 0 {
10898 return Ok ( (
109- input. slice ( input. input_len ( ) .. ) ,
99+ input. take_from ( input. input_len ( ) ) ,
110100 input,
111101 ) ) ;
112102 }
@@ -133,7 +123,7 @@ where
133123 }
134124 }
135125
136- Ok ( ( input. slice ( input. input_len ( ) .. ) , input) )
126+ Ok ( ( input. take_from ( input. input_len ( ) ) , input) )
137127 }
138128}
139129
0 commit comments