@@ -75,9 +75,12 @@ impl<'a> Parser<'a> {
75
75
} )
76
76
}
77
77
78
- /// Read the next character from the input if it matches the target
79
- fn read_given_char ( & mut self , target : char ) -> Option < char > {
80
- self . read_atomically ( |p| p. read_char ( ) . filter ( |& c| c == target) )
78
+ #[ must_use]
79
+ /// Read the next character from the input if it matches the target.
80
+ fn read_given_char ( & mut self , target : char ) -> Option < ( ) > {
81
+ self . read_atomically ( |p| {
82
+ p. read_char ( ) . and_then ( |c| if c == target { Some ( ( ) ) } else { None } )
83
+ } )
81
84
}
82
85
83
86
/// Helper for reading separators in an indexed loop. Reads the separator
@@ -90,7 +93,7 @@ impl<'a> Parser<'a> {
90
93
{
91
94
self . read_atomically ( move |p| {
92
95
if index > 0 {
93
- let _ = p. read_given_char ( sep) ?;
96
+ p. read_given_char ( sep) ?;
94
97
}
95
98
inner ( p)
96
99
} )
@@ -187,8 +190,8 @@ impl<'a> Parser<'a> {
187
190
188
191
// read `::` if previous code parsed less than 8 groups
189
192
// `::` indicates one or more groups of 16 bits of zeros
190
- let _ = p. read_given_char ( ':' ) ?;
191
- let _ = p. read_given_char ( ':' ) ?;
193
+ p. read_given_char ( ':' ) ?;
194
+ p. read_given_char ( ':' ) ?;
192
195
193
196
// Read the back part of the address. The :: must contain at least one
194
197
// set of zeroes, so our max length is 7.
@@ -211,7 +214,7 @@ impl<'a> Parser<'a> {
211
214
/// Read a : followed by a port in base 10.
212
215
fn read_port ( & mut self ) -> Option < u16 > {
213
216
self . read_atomically ( |p| {
214
- let _ = p. read_given_char ( ':' ) ?;
217
+ p. read_given_char ( ':' ) ?;
215
218
p. read_number ( 10 , None )
216
219
} )
217
220
}
@@ -228,9 +231,9 @@ impl<'a> Parser<'a> {
228
231
/// Read an IPV6 address with a port
229
232
fn read_socket_addr_v6 ( & mut self ) -> Option < SocketAddrV6 > {
230
233
self . read_atomically ( |p| {
231
- let _ = p. read_given_char ( '[' ) ?;
234
+ p. read_given_char ( '[' ) ?;
232
235
let ip = p. read_ipv6_addr ( ) ?;
233
- let _ = p. read_given_char ( ']' ) ?;
236
+ p. read_given_char ( ']' ) ?;
234
237
235
238
let port = p. read_port ( ) ?;
236
239
Some ( SocketAddrV6 :: new ( ip, port, 0 , 0 ) )
0 commit comments