Skip to content

Commit bc4b193

Browse files
committed
rollup merge of #24961: nham/net_docs_cleanup
Changes made include adding missing punctuation, adding missing words, and converting uses of "Gets" to "Returns" in libstd/net/addr.rs to make it more consistent with the other documentation. Fixes #24925.
2 parents 2c28348 + 2baeabd commit bc4b193

File tree

4 files changed

+39
-39
lines changed

4 files changed

+39
-39
lines changed

src/libstd/net/addr.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub enum SocketAddr {
4141
#[stable(feature = "rust1", since = "1.0.0")]
4242
pub struct SocketAddrV4 { inner: libc::sockaddr_in }
4343

44-
/// An IPv6 socket address
44+
/// An IPv6 socket address.
4545
#[derive(Copy)]
4646
#[stable(feature = "rust1", since = "1.0.0")]
4747
pub struct SocketAddrV6 { inner: libc::sockaddr_in6 }
@@ -56,7 +56,7 @@ impl SocketAddr {
5656
}
5757
}
5858

59-
/// Gets the IP address associated with this socket address.
59+
/// Returns the IP address associated with this socket address.
6060
#[unstable(feature = "ip_addr", reason = "recent addition")]
6161
pub fn ip(&self) -> IpAddr {
6262
match *self {
@@ -65,7 +65,7 @@ impl SocketAddr {
6565
}
6666
}
6767

68-
/// Gets the port number associated with this socket address
68+
/// Returns the port number associated with this socket address.
6969
#[stable(feature = "rust1", since = "1.0.0")]
7070
pub fn port(&self) -> u16 {
7171
match *self {
@@ -89,15 +89,15 @@ impl SocketAddrV4 {
8989
}
9090
}
9191

92-
/// Gets the IP address associated with this socket address.
92+
/// Returns the IP address associated with this socket address.
9393
#[stable(feature = "rust1", since = "1.0.0")]
9494
pub fn ip(&self) -> &Ipv4Addr {
9595
unsafe {
9696
&*(&self.inner.sin_addr as *const libc::in_addr as *const Ipv4Addr)
9797
}
9898
}
9999

100-
/// Gets the port number associated with this socket address
100+
/// Returns the port number associated with this socket address.
101101
#[stable(feature = "rust1", since = "1.0.0")]
102102
pub fn port(&self) -> u16 { ntoh(self.inner.sin_port) }
103103
}
@@ -120,24 +120,24 @@ impl SocketAddrV6 {
120120
}
121121
}
122122

123-
/// Gets the IP address associated with this socket address.
123+
/// Returns the IP address associated with this socket address.
124124
#[stable(feature = "rust1", since = "1.0.0")]
125125
pub fn ip(&self) -> &Ipv6Addr {
126126
unsafe {
127127
&*(&self.inner.sin6_addr as *const libc::in6_addr as *const Ipv6Addr)
128128
}
129129
}
130130

131-
/// Gets the port number associated with this socket address
131+
/// Returns the port number associated with this socket address.
132132
#[stable(feature = "rust1", since = "1.0.0")]
133133
pub fn port(&self) -> u16 { ntoh(self.inner.sin6_port) }
134134

135-
/// Gets scope ID associated with this address, corresponding to the
135+
/// Returns scope ID associated with this address, corresponding to the
136136
/// `sin6_flowinfo` field in C.
137137
#[stable(feature = "rust1", since = "1.0.0")]
138138
pub fn flowinfo(&self) -> u32 { ntoh(self.inner.sin6_flowinfo) }
139139

140-
/// Gets scope ID associated with this address, corresponding to the
140+
/// Returns scope ID associated with this address, corresponding to the
141141
/// `sin6_scope_id` field in C.
142142
#[stable(feature = "rust1", since = "1.0.0")]
143143
pub fn scope_id(&self) -> u32 { ntoh(self.inner.sin6_scope_id) }

src/libstd/net/ip.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ pub enum Ipv6MulticastScope {
6060
impl Ipv4Addr {
6161
/// Creates a new IPv4 address from four eight-bit octets.
6262
///
63-
/// The result will represent the IP address a.b.c.d
63+
/// The result will represent the IP address `a`.`b`.`c`.`d`.
6464
#[stable(feature = "rust1", since = "1.0.0")]
6565
pub fn new(a: u8, b: u8, c: u8, d: u8) -> Ipv4Addr {
6666
Ipv4Addr {
@@ -73,19 +73,19 @@ impl Ipv4Addr {
7373
}
7474
}
7575

76-
/// Returns the four eight-bit integers that make up this address
76+
/// Returns the four eight-bit integers that make up this address.
7777
#[stable(feature = "rust1", since = "1.0.0")]
7878
pub fn octets(&self) -> [u8; 4] {
7979
let bits = ntoh(self.inner.s_addr);
8080
[(bits >> 24) as u8, (bits >> 16) as u8, (bits >> 8) as u8, bits as u8]
8181
}
8282

83-
/// Returns true for the special 'unspecified' address 0.0.0.0
83+
/// Returns true for the special 'unspecified' address 0.0.0.0.
8484
pub fn is_unspecified(&self) -> bool {
8585
self.inner.s_addr == 0
8686
}
8787

88-
/// Returns true if this is a loopback address (127.0.0.0/8)
88+
/// Returns true if this is a loopback address (127.0.0.0/8).
8989
pub fn is_loopback(&self) -> bool {
9090
self.octets()[0] == 127
9191
}
@@ -106,7 +106,7 @@ impl Ipv4Addr {
106106
}
107107
}
108108

109-
/// Returns true if the address is link-local (169.254.0.0/16)
109+
/// Returns true if the address is link-local (169.254.0.0/16).
110110
pub fn is_link_local(&self) -> bool {
111111
self.octets()[0] == 169 && self.octets()[1] == 254
112112
}
@@ -116,7 +116,7 @@ impl Ipv4Addr {
116116
/// Non-globally-routable networks include the private networks (10.0.0.0/8,
117117
/// 172.16.0.0/12 and 192.168.0.0/16), the loopback network (127.0.0.0/8),
118118
/// the link-local network (169.254.0.0/16), the broadcast address (255.255.255.255/32) and
119-
/// the test networks used for documentation (192.0.2.0/24, 198.51.100.0/24 and 203.0.113.0/24)
119+
/// the test networks used for documentation (192.0.2.0/24, 198.51.100.0/24 and 203.0.113.0/24).
120120
pub fn is_global(&self) -> bool {
121121
!self.is_private() && !self.is_loopback() && !self.is_link_local() &&
122122
!self.is_broadcast() && !self.is_documentation()
@@ -131,13 +131,13 @@ impl Ipv4Addr {
131131

132132
/// Returns true if this is a broadcast address.
133133
///
134-
/// A broadcast address has all octets set to 255 as defined in RFC 919
134+
/// A broadcast address has all octets set to 255 as defined in RFC 919.
135135
pub fn is_broadcast(&self) -> bool {
136136
self.octets()[0] == 255 && self.octets()[1] == 255 &&
137137
self.octets()[2] == 255 && self.octets()[3] == 255
138138
}
139139

140-
/// Returns true if this address is in a range designated for documentation
140+
/// Returns true if this address is in a range designated for documentation.
141141
///
142142
/// This is defined in RFC 5737
143143
/// - 192.0.2.0/24 (TEST-NET-1)
@@ -152,7 +152,7 @@ impl Ipv4Addr {
152152
}
153153
}
154154

155-
/// Converts this address to an IPv4-compatible IPv6 address
155+
/// Converts this address to an IPv4-compatible IPv6 address.
156156
///
157157
/// a.b.c.d becomes ::a.b.c.d
158158
#[stable(feature = "rust1", since = "1.0.0")]
@@ -162,7 +162,7 @@ impl Ipv4Addr {
162162
((self.octets()[2] as u16) << 8) | self.octets()[3] as u16)
163163
}
164164

165-
/// Converts this address to an IPv4-mapped IPv6 address
165+
/// Converts this address to an IPv4-mapped IPv6 address.
166166
///
167167
/// a.b.c.d becomes ::ffff:a.b.c.d
168168
#[stable(feature = "rust1", since = "1.0.0")]
@@ -247,7 +247,7 @@ impl FromInner<libc::in_addr> for Ipv4Addr {
247247
impl Ipv6Addr {
248248
/// Creates a new IPv6 address from eight 16-bit segments.
249249
///
250-
/// The result will represent the IP address a:b:c:d:e:f:g:h
250+
/// The result will represent the IP address a:b:c:d:e:f:g:h.
251251
#[stable(feature = "rust1", since = "1.0.0")]
252252
pub fn new(a: u16, b: u16, c: u16, d: u16, e: u16, f: u16, g: u16,
253253
h: u16) -> Ipv6Addr {
@@ -259,7 +259,7 @@ impl Ipv6Addr {
259259
}
260260
}
261261

262-
/// Returns the eight 16-bit segments that make up this address
262+
/// Returns the eight 16-bit segments that make up this address.
263263
#[stable(feature = "rust1", since = "1.0.0")]
264264
pub fn segments(&self) -> [u16; 8] {
265265
[ntoh(self.inner.s6_addr[0]),
@@ -272,12 +272,12 @@ impl Ipv6Addr {
272272
ntoh(self.inner.s6_addr[7])]
273273
}
274274

275-
/// Returns true for the special 'unspecified' address ::
275+
/// Returns true for the special 'unspecified' address ::.
276276
pub fn is_unspecified(&self) -> bool {
277277
self.segments() == [0, 0, 0, 0, 0, 0, 0, 0]
278278
}
279279

280-
/// Returns true if this is a loopback address (::1)
280+
/// Returns true if this is a loopback address (::1).
281281
pub fn is_loopback(&self) -> bool {
282282
self.segments() == [0, 0, 0, 0, 0, 0, 0, 1]
283283
}
@@ -295,25 +295,25 @@ impl Ipv6Addr {
295295
}
296296
}
297297

298-
/// Returns true if this is a unique local address (IPv6)
298+
/// Returns true if this is a unique local address (IPv6).
299299
///
300-
/// Unique local addresses are defined in RFC4193 and have the form fc00::/7
300+
/// Unique local addresses are defined in RFC4193 and have the form fc00::/7.
301301
pub fn is_unique_local(&self) -> bool {
302302
(self.segments()[0] & 0xfe00) == 0xfc00
303303
}
304304

305-
/// Returns true if the address is unicast and link-local (fe80::/10)
305+
/// Returns true if the address is unicast and link-local (fe80::/10).
306306
pub fn is_unicast_link_local(&self) -> bool {
307307
(self.segments()[0] & 0xffc0) == 0xfe80
308308
}
309309

310310
/// Returns true if this is a deprecated unicast site-local address (IPv6
311-
/// fec0::/10)
311+
/// fec0::/10).
312312
pub fn is_unicast_site_local(&self) -> bool {
313313
(self.segments()[0] & 0xffc0) == 0xfec0
314314
}
315315

316-
/// Returns true if the address is a globally routable unicast address
316+
/// Returns true if the address is a globally routable unicast address.
317317
///
318318
/// Non-globally-routable unicast addresses include the loopback address,
319319
/// the link-local addresses, the deprecated site-local addresses and the

src/libstd/net/tcp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ impl TcpStream {
125125
self.0.duplicate().map(TcpStream)
126126
}
127127

128-
/// Sets the nodelay flag on this connection to the boolean specified
128+
/// Sets the nodelay flag on this connection to the boolean specified.
129129
pub fn set_nodelay(&self, nodelay: bool) -> io::Result<()> {
130130
self.0.set_nodelay(nodelay)
131131
}

src/libstd/net/udp.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ pub struct UdpSocket(net_imp::UdpSocket);
5050
impl UdpSocket {
5151
/// Creates a UDP socket from the given address.
5252
///
53-
/// Address type can be any implementor of `ToSocketAddr` trait. See its
54-
/// documentation for concrete examples.
53+
/// The address type can be any implementor of `ToSocketAddr` trait. See
54+
/// its documentation for concrete examples.
5555
#[stable(feature = "rust1", since = "1.0.0")]
5656
pub fn bind<A: ToSocketAddrs>(addr: A) -> io::Result<UdpSocket> {
5757
super::each_addr(addr, net_imp::UdpSocket::bind).map(UdpSocket)
@@ -64,8 +64,8 @@ impl UdpSocket {
6464
self.0.recv_from(buf)
6565
}
6666

67-
/// Sends data on the socket to the given address. Returns nothing on
68-
/// success.
67+
/// Sends data on the socket to the given address. On success, returns the
68+
/// number of bytes written.
6969
///
7070
/// Address type can be any implementor of `ToSocketAddrs` trait. See its
7171
/// documentation for concrete examples.
@@ -95,34 +95,34 @@ impl UdpSocket {
9595
self.0.duplicate().map(UdpSocket)
9696
}
9797

98-
/// Sets the broadcast flag on or off
98+
/// Sets the broadcast flag on or off.
9999
pub fn set_broadcast(&self, on: bool) -> io::Result<()> {
100100
self.0.set_broadcast(on)
101101
}
102102

103-
/// Sets the multicast loop flag to the specified value
103+
/// Sets the multicast loop flag to the specified value.
104104
///
105105
/// This lets multicast packets loop back to local sockets (if enabled)
106106
pub fn set_multicast_loop(&self, on: bool) -> io::Result<()> {
107107
self.0.set_multicast_loop(on)
108108
}
109109

110-
/// Joins a multicast IP address (becomes a member of it)
110+
/// Joins a multicast IP address (becomes a member of it).
111111
pub fn join_multicast(&self, multi: &IpAddr) -> io::Result<()> {
112112
self.0.join_multicast(multi)
113113
}
114114

115-
/// Leaves a multicast IP address (drops membership from it)
115+
/// Leaves a multicast IP address (drops membership from it).
116116
pub fn leave_multicast(&self, multi: &IpAddr) -> io::Result<()> {
117117
self.0.leave_multicast(multi)
118118
}
119119

120-
/// Sets the multicast TTL
120+
/// Sets the multicast TTL.
121121
pub fn set_multicast_time_to_live(&self, ttl: i32) -> io::Result<()> {
122122
self.0.multicast_time_to_live(ttl)
123123
}
124124

125-
/// Sets this socket's TTL
125+
/// Sets this socket's TTL.
126126
pub fn set_time_to_live(&self, ttl: i32) -> io::Result<()> {
127127
self.0.time_to_live(ttl)
128128
}

0 commit comments

Comments
 (0)