Skip to content

Commit a093957

Browse files
committed
Avoid unused return
1 parent 9fdaeb3 commit a093957

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

library/std/src/net/parser.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,12 @@ impl<'a> Parser<'a> {
7575
})
7676
}
7777

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+
})
8184
}
8285

8386
/// Helper for reading separators in an indexed loop. Reads the separator
@@ -90,7 +93,7 @@ impl<'a> Parser<'a> {
9093
{
9194
self.read_atomically(move |p| {
9295
if index > 0 {
93-
let _ = p.read_given_char(sep)?;
96+
p.read_given_char(sep)?;
9497
}
9598
inner(p)
9699
})
@@ -187,8 +190,8 @@ impl<'a> Parser<'a> {
187190

188191
// read `::` if previous code parsed less than 8 groups
189192
// `::` 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(':')?;
192195

193196
// Read the back part of the address. The :: must contain at least one
194197
// set of zeroes, so our max length is 7.
@@ -211,7 +214,7 @@ impl<'a> Parser<'a> {
211214
/// Read a : followed by a port in base 10.
212215
fn read_port(&mut self) -> Option<u16> {
213216
self.read_atomically(|p| {
214-
let _ = p.read_given_char(':')?;
217+
p.read_given_char(':')?;
215218
p.read_number(10, None)
216219
})
217220
}
@@ -228,9 +231,9 @@ impl<'a> Parser<'a> {
228231
/// Read an IPV6 address with a port
229232
fn read_socket_addr_v6(&mut self) -> Option<SocketAddrV6> {
230233
self.read_atomically(|p| {
231-
let _ = p.read_given_char('[')?;
234+
p.read_given_char('[')?;
232235
let ip = p.read_ipv6_addr()?;
233-
let _ = p.read_given_char(']')?;
236+
p.read_given_char(']')?;
234237

235238
let port = p.read_port()?;
236239
Some(SocketAddrV6::new(ip, port, 0, 0))

0 commit comments

Comments
 (0)