Skip to content

Commit 7e39c0e

Browse files
authored
Auto merge of #38015 - sanxiyn:rollup, r=sanxiyn
Rollup of 7 pull requests - Successful merges: #37962, #37963, #37967, #37978, #37985, #38001, #38010 - Failed merges:
2 parents 73e98a0 + 44b926a commit 7e39c0e

File tree

8 files changed

+119
-14
lines changed

8 files changed

+119
-14
lines changed

src/libcollections/enum_set.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#![unstable(feature = "enumset",
1717
reason = "matches collection reform specification, \
1818
waiting for dust to settle",
19-
issue = "0")]
19+
issue = "37966")]
2020

2121
use core::marker;
2222
use core::fmt;

src/libcore/iter/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -225,12 +225,12 @@
225225
//! often called 'iterator adapters', as they're a form of the 'adapter
226226
//! pattern'.
227227
//!
228-
//! Common iterator adapters include [`map()`], [`take()`], and [`collect()`].
228+
//! Common iterator adapters include [`map()`], [`take()`], and [`filter()`].
229229
//! For more, see their documentation.
230230
//!
231231
//! [`map()`]: trait.Iterator.html#method.map
232232
//! [`take()`]: trait.Iterator.html#method.take
233-
//! [`collect()`]: trait.Iterator.html#method.collect
233+
//! [`filter()`]: trait.Iterator.html#method.filter
234234
//!
235235
//! # Laziness
236236
//!
@@ -268,7 +268,7 @@
268268
//! [`map()`]: trait.Iterator.html#method.map
269269
//!
270270
//! The two most common ways to evaluate an iterator are to use a `for` loop
271-
//! like this, or using the [`collect()`] adapter to produce a new collection.
271+
//! like this, or using the [`collect()`] method to produce a new collection.
272272
//!
273273
//! [`collect()`]: trait.Iterator.html#method.collect
274274
//!
@@ -937,7 +937,7 @@ unsafe impl<A, B> TrustedLen for Zip<A, B>
937937
/// you can also [`map()`] backwards:
938938
///
939939
/// ```rust
940-
/// let v: Vec<i32> = vec![1, 2, 3].into_iter().rev().map(|x| x + 1).collect();
940+
/// let v: Vec<i32> = vec![1, 2, 3].into_iter().map(|x| x + 1).rev().collect();
941941
///
942942
/// assert_eq!(v, [4, 3, 2]);
943943
/// ```

src/libstd/error.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ pub trait Error: Debug + Display {
109109
///
110110
/// impl Error for SuperError {
111111
/// fn description(&self) -> &str {
112-
/// "I'm the superhero of errors!"
112+
/// "I'm the superhero of errors"
113113
/// }
114114
///
115115
/// fn cause(&self) -> Option<&Error> {
@@ -128,7 +128,7 @@ pub trait Error: Debug + Display {
128128
///
129129
/// impl Error for SuperErrorSideKick {
130130
/// fn description(&self) -> &str {
131-
/// "I'm SuperError side kick!"
131+
/// "I'm SuperError side kick"
132132
/// }
133133
/// }
134134
///

src/libstd/net/addr.rs

+84
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,14 @@ impl SocketAddrV4 {
282282
impl SocketAddrV6 {
283283
/// Creates a new socket address from the ip/port/flowinfo/scope_id
284284
/// components.
285+
///
286+
/// # Examples
287+
///
288+
/// ```
289+
/// use std::net::{SocketAddrV6, Ipv6Addr};
290+
///
291+
/// let socket = SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), 8080, 0, 0);
292+
/// ```
285293
#[stable(feature = "rust1", since = "1.0.0")]
286294
pub fn new(ip: Ipv6Addr, port: u16, flowinfo: u32, scope_id: u32)
287295
-> SocketAddrV6 {
@@ -298,6 +306,15 @@ impl SocketAddrV6 {
298306
}
299307

300308
/// Returns the IP address associated with this socket address.
309+
///
310+
/// # Examples
311+
///
312+
/// ```
313+
/// use std::net::{SocketAddrV6, Ipv6Addr};
314+
///
315+
/// let socket = SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), 8080, 0, 0);
316+
/// assert_eq!(socket.ip(), &Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1));
317+
/// ```
301318
#[stable(feature = "rust1", since = "1.0.0")]
302319
pub fn ip(&self) -> &Ipv6Addr {
303320
unsafe {
@@ -306,44 +323,111 @@ impl SocketAddrV6 {
306323
}
307324

308325
/// Change the IP address associated with this socket address.
326+
///
327+
/// # Examples
328+
///
329+
/// ```
330+
/// use std::net::{SocketAddrV6, Ipv6Addr};
331+
///
332+
/// let mut socket = SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), 8080, 0, 0);
333+
/// socket.set_ip(Ipv6Addr::new(76, 45, 0, 0, 0, 0, 0, 0));
334+
/// assert_eq!(socket.ip(), &Ipv6Addr::new(76, 45, 0, 0, 0, 0, 0, 0));
335+
/// ```
309336
#[stable(feature = "sockaddr_setters", since = "1.9.0")]
310337
pub fn set_ip(&mut self, new_ip: Ipv6Addr) {
311338
self.inner.sin6_addr = *new_ip.as_inner()
312339
}
313340

314341
/// Returns the port number associated with this socket address.
342+
///
343+
/// # Examples
344+
///
345+
/// ```
346+
/// use std::net::{SocketAddrV6, Ipv6Addr};
347+
///
348+
/// let socket = SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), 8080, 0, 0);
349+
/// assert_eq!(socket.port(), 8080);
350+
/// ```
315351
#[stable(feature = "rust1", since = "1.0.0")]
316352
pub fn port(&self) -> u16 {
317353
ntoh(self.inner.sin6_port)
318354
}
319355

320356
/// Change the port number associated with this socket address.
357+
///
358+
/// # Examples
359+
///
360+
/// ```
361+
/// use std::net::{SocketAddrV6, Ipv6Addr};
362+
///
363+
/// let mut socket = SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), 8080, 0, 0);
364+
/// socket.set_port(4242);
365+
/// assert_eq!(socket.port(), 4242);
366+
/// ```
321367
#[stable(feature = "sockaddr_setters", since = "1.9.0")]
322368
pub fn set_port(&mut self, new_port: u16) {
323369
self.inner.sin6_port = hton(new_port);
324370
}
325371

326372
/// Returns the flow information associated with this address,
327373
/// corresponding to the `sin6_flowinfo` field in C.
374+
///
375+
/// # Examples
376+
///
377+
/// ```
378+
/// use std::net::{SocketAddrV6, Ipv6Addr};
379+
///
380+
/// let socket = SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), 8080, 10, 0);
381+
/// assert_eq!(socket.flowinfo(), 10);
382+
/// ```
328383
#[stable(feature = "rust1", since = "1.0.0")]
329384
pub fn flowinfo(&self) -> u32 {
330385
self.inner.sin6_flowinfo
331386
}
332387

333388
/// Change the flow information associated with this socket address.
389+
///
390+
/// # Examples
391+
///
392+
/// ```
393+
/// use std::net::{SocketAddrV6, Ipv6Addr};
394+
///
395+
/// let mut socket = SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), 8080, 10, 0);
396+
/// socket.set_flowinfo(56);
397+
/// assert_eq!(socket.flowinfo(), 56);
398+
/// ```
334399
#[stable(feature = "sockaddr_setters", since = "1.9.0")]
335400
pub fn set_flowinfo(&mut self, new_flowinfo: u32) {
336401
self.inner.sin6_flowinfo = new_flowinfo;
337402
}
338403

339404
/// Returns the scope ID associated with this address,
340405
/// corresponding to the `sin6_scope_id` field in C.
406+
///
407+
/// # Examples
408+
///
409+
/// ```
410+
/// use std::net::{SocketAddrV6, Ipv6Addr};
411+
///
412+
/// let socket = SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), 8080, 0, 78);
413+
/// assert_eq!(socket.scope_id(), 78);
414+
/// ```
341415
#[stable(feature = "rust1", since = "1.0.0")]
342416
pub fn scope_id(&self) -> u32 {
343417
self.inner.sin6_scope_id
344418
}
345419

346420
/// Change the scope ID associated with this socket address.
421+
///
422+
/// # Examples
423+
///
424+
/// ```
425+
/// use std::net::{SocketAddrV6, Ipv6Addr};
426+
///
427+
/// let mut socket = SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), 8080, 0, 78);
428+
/// socket.set_scope_id(42);
429+
/// assert_eq!(socket.scope_id(), 42);
430+
/// ```
347431
#[stable(feature = "sockaddr_setters", since = "1.9.0")]
348432
pub fn set_scope_id(&mut self, new_scope_id: u32) {
349433
self.inner.sin6_scope_id = new_scope_id;

src/libstd/panicking.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ pub fn take_hook() -> Box<Fn(&PanicInfo) + 'static + Sync + Send> {
153153

154154
match hook {
155155
Hook::Default => Box::new(default_hook),
156-
Hook::Custom(ptr) => {Box::from_raw(ptr)} // FIXME #30530
156+
Hook::Custom(ptr) => Box::from_raw(ptr),
157157
}
158158
}
159159
}

src/libstd/sync/mpsc/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -491,11 +491,11 @@ pub fn channel<T>() -> (Sender<T>, Receiver<T>) {
491491
/// becomes available. These channels differ greatly in the semantics of the
492492
/// sender from asynchronous channels, however.
493493
///
494-
/// This channel has an internal buffer on which messages will be queued. When
495-
/// the internal buffer becomes full, future sends will *block* waiting for the
496-
/// buffer to open up. Note that a buffer size of 0 is valid, in which case this
497-
/// becomes "rendezvous channel" where each send will not return until a recv
498-
/// is paired with it.
494+
/// This channel has an internal buffer on which messages will be queued. `bound`
495+
/// specifies the buffer size. When the internal buffer becomes full, future sends
496+
/// will *block* waiting for the buffer to open up. Note that a buffer size of 0
497+
/// is valid, in which case this becomes "rendezvous channel" where each send will
498+
/// not return until a recv is paired with it.
499499
///
500500
/// As with asynchronous channels, all senders will panic in `send` if the
501501
/// `Receiver` has been destroyed.

src/libstd/sync/mutex.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,14 @@ unsafe impl<T: ?Sized + Send> Sync for Mutex<T> { }
133133
/// dropped (falls out of scope), the lock will be unlocked.
134134
///
135135
/// The data protected by the mutex can be access through this guard via its
136-
/// `Deref` and `DerefMut` implementations
136+
/// `Deref` and `DerefMut` implementations.
137+
///
138+
/// This structure is created by the [`lock()`] and [`try_lock()`] methods on
139+
/// [`Mutex`].
140+
///
141+
/// [`lock()`]: struct.Mutex.html#method.lock
142+
/// [`try_lock()`]: struct.Mutex.html#method.try_lock
143+
/// [`Mutex`]: struct.Mutex.html
137144
#[must_use]
138145
#[stable(feature = "rust1", since = "1.0.0")]
139146
pub struct MutexGuard<'a, T: ?Sized + 'a> {

src/libstd/sync/rwlock.rs

+14
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ unsafe impl<T: ?Sized + Send + Sync> Sync for RwLock<T> {}
7777

7878
/// RAII structure used to release the shared read access of a lock when
7979
/// dropped.
80+
///
81+
/// This structure is created by the [`read()`] and [`try_read()`] methods on
82+
/// [`RwLock`].
83+
///
84+
/// [`read()`]: struct.RwLock.html#method.read
85+
/// [`try_read()`]: struct.RwLock.html#method.try_read
86+
/// [`RwLock`]: struct.RwLock.html
8087
#[must_use]
8188
#[stable(feature = "rust1", since = "1.0.0")]
8289
pub struct RwLockReadGuard<'a, T: ?Sized + 'a> {
@@ -88,6 +95,13 @@ impl<'a, T: ?Sized> !marker::Send for RwLockReadGuard<'a, T> {}
8895

8996
/// RAII structure used to release the exclusive write access of a lock when
9097
/// dropped.
98+
///
99+
/// This structure is created by the [`write()`] and [`try_write()`] methods
100+
/// on [`RwLock`].
101+
///
102+
/// [`write()`]: struct.RwLock.html#method.write
103+
/// [`try_write()`]: struct.RwLock.html#method.try_write
104+
/// [`RwLock`]: struct.RwLock.html
91105
#[must_use]
92106
#[stable(feature = "rust1", since = "1.0.0")]
93107
pub struct RwLockWriteGuard<'a, T: ?Sized + 'a> {

0 commit comments

Comments
 (0)