@@ -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,13 @@ 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 ) -> PResult < Cow < ' i , str > , ( ) > {
24
+ #[ allow( clippy:: result_unit_err) ]
25
+ pub fn sq_dequote < ' i > ( input : & mut & ' i str ) -> Result < Cow < ' i , str > , ( ) > {
24
26
// See git's quote.c's `sq_dequote_step`
25
27
alt ( ( sq_dequote_escaped, sq_dequote_no_escaped) ) . parse_next ( input)
26
28
}
27
29
28
- fn sq_dequote_escaped < ' i > ( input : & mut & ' i str ) -> PResult < Cow < ' i , str > , ( ) > {
30
+ fn sq_dequote_escaped < ' i > ( input : & mut & ' i str ) -> Result < Cow < ' i , str > , ( ) > {
29
31
(
30
32
sq_dequote_section,
31
33
sq_dequote_trail,
@@ -40,22 +42,22 @@ fn sq_dequote_escaped<'i>(input: &mut &'i str) -> PResult<Cow<'i, str>, ()> {
40
42
. parse_next ( input)
41
43
}
42
44
43
- fn sq_dequote_no_escaped < ' i > ( input : & mut & ' i str ) -> PResult < Cow < ' i , str > , ( ) > {
45
+ fn sq_dequote_no_escaped < ' i > ( input : & mut & ' i str ) -> Result < Cow < ' i , str > , ( ) > {
44
46
sq_dequote_section. map ( Cow :: Borrowed ) . parse_next ( input)
45
47
}
46
48
47
- fn sq_dequote_section < ' i > ( input : & mut & ' i str ) -> PResult < & ' i str , ( ) > {
49
+ fn sq_dequote_section < ' i > ( input : & mut & ' i str ) -> Result < & ' i str , ( ) > {
48
50
terminated ( preceded ( '\'' , take_while ( 0 .., |c| c != '\'' ) ) , '\'' ) . parse_next ( input)
49
51
}
50
52
51
- fn sq_dequote_trail < ' i > ( input : & mut & ' i str ) -> PResult < [ & ' i str ; 2 ] , ( ) > {
53
+ fn sq_dequote_trail < ' i > ( input : & mut & ' i str ) -> Result < [ & ' i str ; 2 ] , ( ) > {
52
54
( escaped, sq_dequote_section)
53
55
. map ( |( e, s) | [ e, s] )
54
56
. parse_next ( input)
55
57
}
56
58
57
- fn escaped < ' i > ( input : & mut & ' i str ) -> PResult < & ' i str , ( ) > {
58
- preceded ( '\\' , one_of ( [ '\'' , '!' ] ) . recognize ( ) ) . parse_next ( input)
59
+ fn escaped < ' i > ( input : & mut & ' i str ) -> Result < & ' i str , ( ) > {
60
+ preceded ( '\\' , one_of ( [ '\'' , '!' ] ) . take ( ) ) . parse_next ( input)
59
61
}
60
62
61
63
#[ cfg( test) ]
0 commit comments