Skip to content

Commit 8c3c9c2

Browse files
authored
Rollup merge of rust-lang#37941 - Cobrand:docfix-issue-37915, r=GuillaumeGomez
Improve and fix mpsc documentation Closes rust-lang#37915 This commit enhances documentation with several links and fixes an error in the `sync_channel` documentation as well: `send` doesn't panic when the senders are all disconnected r? @steveklabnik
2 parents dc1a094 + 57f998a commit 8c3c9c2

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

src/libstd/sync/mpsc/mod.rs

+20-9
Original file line numberDiff line numberDiff line change
@@ -454,10 +454,16 @@ impl<T> UnsafeFlavor<T> for Receiver<T> {
454454
}
455455

456456
/// Creates a new asynchronous channel, returning the sender/receiver halves.
457-
///
458457
/// All data sent on the sender will become available on the receiver, and no
459458
/// send will block the calling thread (this channel has an "infinite buffer").
460459
///
460+
/// If the [`Receiver`] is disconnected while trying to [`send()`] with the
461+
/// [`Sender`], the [`send()`] method will return an error.
462+
///
463+
/// [`send()`]: ../../../std/sync/mpsc/struct.Sender.html#method.send
464+
/// [`Sender`]: ../../../std/sync/mpsc/struct.Sender.html
465+
/// [`Receiver`]: ../../../std/sync/mpsc/struct.Receiver.html
466+
///
461467
/// # Examples
462468
///
463469
/// ```
@@ -487,18 +493,23 @@ pub fn channel<T>() -> (Sender<T>, Receiver<T>) {
487493

488494
/// Creates a new synchronous, bounded channel.
489495
///
490-
/// Like asynchronous channels, the `Receiver` will block until a message
496+
/// Like asynchronous channels, the [`Receiver`] will block until a message
491497
/// becomes available. These channels differ greatly in the semantics of the
492498
/// sender from asynchronous channels, however.
493499
///
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.
500+
/// This channel has an internal buffer on which messages will be queued.
501+
/// `bound` specifies the buffer size. When the internal buffer becomes full,
502+
/// future sends will *block* waiting for the buffer to open up. Note that a
503+
/// buffer size of 0 is valid, in which case this becomes "rendezvous channel"
504+
/// where each [`send()`] will not return until a recv is paired with it.
505+
///
506+
/// Like asynchronous channels, if the [`Receiver`] is disconnected while
507+
/// trying to [`send()`] with the [`SyncSender`], the [`send()`] method will
508+
/// return an error.
499509
///
500-
/// As with asynchronous channels, all senders will panic in `send` if the
501-
/// `Receiver` has been destroyed.
510+
/// [`send()`]: ../../../std/sync/mpsc/struct.SyncSender.html#method.send
511+
/// [`SyncSender`]: ../../../std/sync/mpsc/struct.SyncSender.html
512+
/// [`Receiver`]: ../../../std/sync/mpsc/struct.Receiver.html
502513
///
503514
/// # Examples
504515
///

0 commit comments

Comments
 (0)