@@ -4,6 +4,7 @@ use itertools::Itertools;
4
4
use winnow:: combinator:: { alt, preceded, repeat, terminated} ;
5
5
use winnow:: prelude:: * ;
6
6
use winnow:: token:: { one_of, take_while} ;
7
+ use winnow:: Result ;
7
8
8
9
#[ derive( Debug ) ]
9
10
pub struct QuoteError ;
@@ -20,12 +21,12 @@ pub fn sq_dequote_step<'i>(input: &mut &'i str) -> Result<Cow<'i, str>, QuoteErr
20
21
sq_dequote. parse_next ( input) . map_err ( |_e| QuoteError )
21
22
}
22
23
23
- pub fn sq_dequote < ' i > ( input : & mut & ' i str ) -> ModalResult < Cow < ' i , str > , ( ) > {
24
+ pub fn sq_dequote < ' i > ( input : & mut & ' i str ) -> Result < Cow < ' i , str > , ( ) > {
24
25
// See git's quote.c's `sq_dequote_step`
25
26
alt ( ( sq_dequote_escaped, sq_dequote_no_escaped) ) . parse_next ( input)
26
27
}
27
28
28
- fn sq_dequote_escaped < ' i > ( input : & mut & ' i str ) -> ModalResult < Cow < ' i , str > , ( ) > {
29
+ fn sq_dequote_escaped < ' i > ( input : & mut & ' i str ) -> Result < Cow < ' i , str > , ( ) > {
29
30
(
30
31
sq_dequote_section,
31
32
sq_dequote_trail,
@@ -40,21 +41,21 @@ fn sq_dequote_escaped<'i>(input: &mut &'i str) -> ModalResult<Cow<'i, str>, ()>
40
41
. parse_next ( input)
41
42
}
42
43
43
- fn sq_dequote_no_escaped < ' i > ( input : & mut & ' i str ) -> ModalResult < Cow < ' i , str > , ( ) > {
44
+ fn sq_dequote_no_escaped < ' i > ( input : & mut & ' i str ) -> Result < Cow < ' i , str > , ( ) > {
44
45
sq_dequote_section. map ( Cow :: Borrowed ) . parse_next ( input)
45
46
}
46
47
47
- fn sq_dequote_section < ' i > ( input : & mut & ' i str ) -> ModalResult < & ' i str , ( ) > {
48
+ fn sq_dequote_section < ' i > ( input : & mut & ' i str ) -> Result < & ' i str , ( ) > {
48
49
terminated ( preceded ( '\'' , take_while ( 0 .., |c| c != '\'' ) ) , '\'' ) . parse_next ( input)
49
50
}
50
51
51
- fn sq_dequote_trail < ' i > ( input : & mut & ' i str ) -> ModalResult < [ & ' i str ; 2 ] , ( ) > {
52
+ fn sq_dequote_trail < ' i > ( input : & mut & ' i str ) -> Result < [ & ' i str ; 2 ] , ( ) > {
52
53
( escaped, sq_dequote_section)
53
54
. map ( |( e, s) | [ e, s] )
54
55
. parse_next ( input)
55
56
}
56
57
57
- fn escaped < ' i > ( input : & mut & ' i str ) -> ModalResult < & ' i str , ( ) > {
58
+ fn escaped < ' i > ( input : & mut & ' i str ) -> Result < & ' i str , ( ) > {
58
59
preceded ( '\\' , one_of ( [ '\'' , '!' ] ) . take ( ) ) . parse_next ( input)
59
60
}
60
61
0 commit comments