Skip to content

Commit 3122510

Browse files
authored
Rollup merge of #82826 - pierwill:fix-IPv, r=JohnTitor
(std::net::parser): Fix capitalization of IP version names Also add some missing puctuation in doc and code comments.
2 parents a16db3d + b86c0d8 commit 3122510

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

library/std/src/net/parser.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ macro_rules! impl_helper {
3535
impl_helper! { u8 u16 u32 }
3636

3737
struct Parser<'a> {
38-
// parsing as ASCII, so can use byte array
38+
// Parsing as ASCII, so can use byte array.
3939
state: &'a [u8],
4040
}
4141

@@ -44,7 +44,7 @@ impl<'a> Parser<'a> {
4444
Parser { state: input.as_bytes() }
4545
}
4646

47-
/// Run a parser, and restore the pre-parse state if it fails
47+
/// Run a parser, and restore the pre-parse state if it fails.
4848
fn read_atomically<T, F>(&mut self, inner: F) -> Option<T>
4949
where
5050
F: FnOnce(&mut Parser<'_>) -> Option<T>,
@@ -126,7 +126,7 @@ impl<'a> Parser<'a> {
126126
})
127127
}
128128

129-
/// Read an IPv4 address
129+
/// Read an IPv4 address.
130130
fn read_ipv4_addr(&mut self) -> Option<Ipv4Addr> {
131131
self.read_atomically(|p| {
132132
let mut groups = [0; 4];
@@ -139,18 +139,18 @@ impl<'a> Parser<'a> {
139139
})
140140
}
141141

142-
/// Read an IPV6 Address
142+
/// Read an IPv6 Address.
143143
fn read_ipv6_addr(&mut self) -> Option<Ipv6Addr> {
144-
/// Read a chunk of an ipv6 address into `groups`. Returns the number
144+
/// Read a chunk of an IPv6 address into `groups`. Returns the number
145145
/// of groups read, along with a bool indicating if an embedded
146-
/// trailing ipv4 address was read. Specifically, read a series of
147-
/// colon-separated ipv6 groups (0x0000 - 0xFFFF), with an optional
148-
/// trailing embedded ipv4 address.
146+
/// trailing IPv4 address was read. Specifically, read a series of
147+
/// colon-separated IPv6 groups (0x0000 - 0xFFFF), with an optional
148+
/// trailing embedded IPv4 address.
149149
fn read_groups(p: &mut Parser<'_>, groups: &mut [u16]) -> (usize, bool) {
150150
let limit = groups.len();
151151

152152
for (i, slot) in groups.iter_mut().enumerate() {
153-
// Try to read a trailing embedded ipv4 address. There must be
153+
// Try to read a trailing embedded IPv4 address. There must be
154154
// at least two groups left.
155155
if i < limit - 1 {
156156
let ipv4 = p.read_separator(':', i, |p| p.read_ipv4_addr());
@@ -188,8 +188,8 @@ impl<'a> Parser<'a> {
188188
return None;
189189
}
190190

191-
// read `::` if previous code parsed less than 8 groups
192-
// `::` indicates one or more groups of 16 bits of zeros
191+
// Read `::` if previous code parsed less than 8 groups.
192+
// `::` indicates one or more groups of 16 bits of zeros.
193193
p.read_given_char(':')?;
194194
p.read_given_char(':')?;
195195

@@ -206,28 +206,28 @@ impl<'a> Parser<'a> {
206206
})
207207
}
208208

209-
/// Read an IP Address, either IPV4 or IPV6.
209+
/// Read an IP Address, either IPv4 or IPv6.
210210
fn read_ip_addr(&mut self) -> Option<IpAddr> {
211211
self.read_ipv4_addr().map(IpAddr::V4).or_else(move || self.read_ipv6_addr().map(IpAddr::V6))
212212
}
213213

214-
/// Read a : followed by a port in base 10.
214+
/// Read a `:` followed by a port in base 10.
215215
fn read_port(&mut self) -> Option<u16> {
216216
self.read_atomically(|p| {
217217
p.read_given_char(':')?;
218218
p.read_number(10, None)
219219
})
220220
}
221221

222-
/// Read a % followed by a scope id in base 10.
222+
/// Read a `%` followed by a scope ID in base 10.
223223
fn read_scope_id(&mut self) -> Option<u32> {
224224
self.read_atomically(|p| {
225225
p.read_given_char('%')?;
226226
p.read_number(10, None)
227227
})
228228
}
229229

230-
/// Read an IPV4 address with a port
230+
/// Read an IPv4 address with a port.
231231
fn read_socket_addr_v4(&mut self) -> Option<SocketAddrV4> {
232232
self.read_atomically(|p| {
233233
let ip = p.read_ipv4_addr()?;
@@ -236,7 +236,7 @@ impl<'a> Parser<'a> {
236236
})
237237
}
238238

239-
/// Read an IPV6 address with a port
239+
/// Read an IPv6 address with a port.
240240
fn read_socket_addr_v6(&mut self) -> Option<SocketAddrV6> {
241241
self.read_atomically(|p| {
242242
p.read_given_char('[')?;

0 commit comments

Comments
 (0)