@@ -26,8 +26,8 @@ pub struct RemoteProgress<'a> {
26
26
27
27
impl < ' a > RemoteProgress < ' a > {
28
28
/// Parse the progress from a typical git progress `line` as sent by the remote.
29
- pub fn from_bytes ( line : & [ u8 ] ) -> Option < RemoteProgress < ' _ > > {
30
- parse_progress ( line) . ok ( ) . and_then ( |( _ , r ) | {
29
+ pub fn from_bytes ( mut line : & [ u8 ] ) -> Option < RemoteProgress < ' _ > > {
30
+ parse_progress ( & mut line) . ok ( ) . and_then ( |r | {
31
31
if r. percent . is_none ( ) && r. step . is_none ( ) && r. max . is_none ( ) {
32
32
None
33
33
} else {
@@ -74,13 +74,13 @@ impl<'a> RemoteProgress<'a> {
74
74
}
75
75
}
76
76
77
- fn parse_number ( i : & [ u8 ] ) -> winnow :: IResult < & [ u8 ] , usize > {
77
+ fn parse_number ( i : & mut & [ u8 ] ) -> PResult < usize > {
78
78
take_till0 ( |c : u8 | !c. is_ascii_digit ( ) )
79
79
. try_map ( btoi:: btoi)
80
80
. parse_next ( i)
81
81
}
82
82
83
- fn next_optional_percentage ( i : & [ u8 ] ) -> winnow :: IResult < & [ u8 ] , Option < u32 > > {
83
+ fn next_optional_percentage ( i : & mut & [ u8 ] ) -> PResult < Option < u32 > > {
84
84
opt ( terminated (
85
85
preceded (
86
86
take_till0 ( |c : u8 | c. is_ascii_digit ( ) ) ,
@@ -91,22 +91,19 @@ fn next_optional_percentage(i: &[u8]) -> winnow::IResult<&[u8], Option<u32>> {
91
91
. parse_next ( i)
92
92
}
93
93
94
- fn next_optional_number ( i : & [ u8 ] ) -> winnow :: IResult < & [ u8 ] , Option < usize > > {
94
+ fn next_optional_number ( i : & mut & [ u8 ] ) -> PResult < Option < usize > > {
95
95
opt ( preceded ( take_till0 ( |c : u8 | c. is_ascii_digit ( ) ) , parse_number) ) . parse_next ( i)
96
96
}
97
97
98
- fn parse_progress ( line : & [ u8 ] ) -> winnow:: IResult < & [ u8 ] , RemoteProgress < ' _ > > {
99
- let ( i, action) = take_till1 ( |c| c == b':' ) . parse_next ( line) ?;
100
- let ( i, percent) = next_optional_percentage. parse_next ( i) ?;
101
- let ( i, step) = next_optional_number. parse_next ( i) ?;
102
- let ( i, max) = next_optional_number. parse_next ( i) ?;
103
- Ok ( (
104
- i,
105
- RemoteProgress {
106
- action : action. into ( ) ,
107
- percent,
108
- step,
109
- max,
110
- } ,
111
- ) )
98
+ fn parse_progress < ' i > ( line : & mut & ' i [ u8 ] ) -> PResult < RemoteProgress < ' i > > {
99
+ let action = take_till1 ( |c| c == b':' ) . parse_next ( line) ?;
100
+ let percent = next_optional_percentage. parse_next ( line) ?;
101
+ let step = next_optional_number. parse_next ( line) ?;
102
+ let max = next_optional_number. parse_next ( line) ?;
103
+ Ok ( RemoteProgress {
104
+ action : action. into ( ) ,
105
+ percent,
106
+ step,
107
+ max,
108
+ } )
112
109
}
0 commit comments