@@ -35,7 +35,7 @@ macro_rules! impl_helper {
35
35
impl_helper ! { u8 u16 u32 }
36
36
37
37
struct Parser < ' a > {
38
- // parsing as ASCII, so can use byte array
38
+ // Parsing as ASCII, so can use byte array.
39
39
state : & ' a [ u8 ] ,
40
40
}
41
41
@@ -44,7 +44,7 @@ impl<'a> Parser<'a> {
44
44
Parser { state : input. as_bytes ( ) }
45
45
}
46
46
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.
48
48
fn read_atomically < T , F > ( & mut self , inner : F ) -> Option < T >
49
49
where
50
50
F : FnOnce ( & mut Parser < ' _ > ) -> Option < T > ,
@@ -126,7 +126,7 @@ impl<'a> Parser<'a> {
126
126
} )
127
127
}
128
128
129
- /// Read an IPv4 address
129
+ /// Read an IPv4 address.
130
130
fn read_ipv4_addr ( & mut self ) -> Option < Ipv4Addr > {
131
131
self . read_atomically ( |p| {
132
132
let mut groups = [ 0 ; 4 ] ;
@@ -139,18 +139,18 @@ impl<'a> Parser<'a> {
139
139
} )
140
140
}
141
141
142
- /// Read an IPV6 Address
142
+ /// Read an IPv6 Address.
143
143
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
145
145
/// 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.
149
149
fn read_groups ( p : & mut Parser < ' _ > , groups : & mut [ u16 ] ) -> ( usize , bool ) {
150
150
let limit = groups. len ( ) ;
151
151
152
152
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
154
154
// at least two groups left.
155
155
if i < limit - 1 {
156
156
let ipv4 = p. read_separator ( ':' , i, |p| p. read_ipv4_addr ( ) ) ;
@@ -188,8 +188,8 @@ impl<'a> Parser<'a> {
188
188
return None ;
189
189
}
190
190
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.
193
193
p. read_given_char ( ':' ) ?;
194
194
p. read_given_char ( ':' ) ?;
195
195
@@ -206,28 +206,28 @@ impl<'a> Parser<'a> {
206
206
} )
207
207
}
208
208
209
- /// Read an IP Address, either IPV4 or IPV6 .
209
+ /// Read an IP Address, either IPv4 or IPv6 .
210
210
fn read_ip_addr ( & mut self ) -> Option < IpAddr > {
211
211
self . read_ipv4_addr ( ) . map ( IpAddr :: V4 ) . or_else ( move || self . read_ipv6_addr ( ) . map ( IpAddr :: V6 ) )
212
212
}
213
213
214
- /// Read a : followed by a port in base 10.
214
+ /// Read a `:` followed by a port in base 10.
215
215
fn read_port ( & mut self ) -> Option < u16 > {
216
216
self . read_atomically ( |p| {
217
217
p. read_given_char ( ':' ) ?;
218
218
p. read_number ( 10 , None )
219
219
} )
220
220
}
221
221
222
- /// Read a % followed by a scope id in base 10.
222
+ /// Read a `%` followed by a scope ID in base 10.
223
223
fn read_scope_id ( & mut self ) -> Option < u32 > {
224
224
self . read_atomically ( |p| {
225
225
p. read_given_char ( '%' ) ?;
226
226
p. read_number ( 10 , None )
227
227
} )
228
228
}
229
229
230
- /// Read an IPV4 address with a port
230
+ /// Read an IPv4 address with a port.
231
231
fn read_socket_addr_v4 ( & mut self ) -> Option < SocketAddrV4 > {
232
232
self . read_atomically ( |p| {
233
233
let ip = p. read_ipv4_addr ( ) ?;
@@ -236,7 +236,7 @@ impl<'a> Parser<'a> {
236
236
} )
237
237
}
238
238
239
- /// Read an IPV6 address with a port
239
+ /// Read an IPv6 address with a port.
240
240
fn read_socket_addr_v6 ( & mut self ) -> Option < SocketAddrV6 > {
241
241
self . read_atomically ( |p| {
242
242
p. read_given_char ( '[' ) ?;
0 commit comments