From ab78a9e6b86b17f370185596bb3cbc63a156b7dd Mon Sep 17 00:00:00 2001 From: Martin Geisler Date: Fri, 18 Oct 2024 03:05:01 -0400 Subject: [PATCH] Links in channel pages (#2441) --- src/concurrency/channels/bounded.md | 13 ++++++++----- src/concurrency/channels/senders-receivers.md | 14 ++++++++++---- src/concurrency/channels/unbounded.md | 4 +++- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/concurrency/channels/bounded.md b/src/concurrency/channels/bounded.md index bde5752a8f7..8d492883e51 100644 --- a/src/concurrency/channels/bounded.md +++ b/src/concurrency/channels/bounded.md @@ -4,7 +4,7 @@ minutes: 8 # Bounded Channels -With bounded (synchronous) channels, `send` can block the current thread: +With bounded (synchronous) channels, [`send()`] can block the current thread: ```rust,editable use std::sync::mpsc; @@ -32,12 +32,15 @@ fn main() {
-- Calling `send` will block the current thread until there is space in the +- Calling `send()` will block the current thread until there is space in the channel for the new message. The thread can be blocked indefinitely if there is nobody who reads from the channel. -- A call to `send` will abort with an error (that is why it returns `Result`) if - the channel is closed. A channel is closed when the receiver is dropped. +- A call to `send()` will abort with an error (that is why it returns `Result`) + if the channel is closed. A channel is closed when the receiver is dropped. - A bounded channel with a size of zero is called a "rendezvous channel". Every - send will block the current thread until another thread calls `recv`. + send will block the current thread until another thread calls [`recv()`].
+ +[`send()`]: https://doc.rust-lang.org/std/sync/mpsc/struct.SyncSender.html#method.send +[`recv()`]: https://doc.rust-lang.org/std/sync/mpsc/struct.Receiver.html#method.recv diff --git a/src/concurrency/channels/senders-receivers.md b/src/concurrency/channels/senders-receivers.md index c0ece3576a6..2609196efd7 100644 --- a/src/concurrency/channels/senders-receivers.md +++ b/src/concurrency/channels/senders-receivers.md @@ -4,8 +4,8 @@ minutes: 9 # Senders and Receivers -Rust channels have two parts: a `Sender` and a `Receiver`. The two parts -are connected via the channel, but you only see the end-points. +Rust channels have two parts: a [`Sender`] and a [`Receiver`]. The two +parts are connected via the channel, but you only see the end-points. ```rust,editable use std::sync::mpsc; @@ -27,10 +27,16 @@ fn main() {
-- `mpsc` stands for Multi-Producer, Single-Consumer. `Sender` and `SyncSender` +- [`mpsc`] stands for Multi-Producer, Single-Consumer. `Sender` and `SyncSender` implement `Clone` (so you can make multiple producers) but `Receiver` does not. -- `send()` and `recv()` return `Result`. If they return `Err`, it means the +- [`send()`] and [`recv()`] return `Result`. If they return `Err`, it means the counterpart `Sender` or `Receiver` is dropped and the channel is closed.
+ +[`Sender`]: https://doc.rust-lang.org/std/sync/mpsc/struct.Sender.html +[`Receiver`]: https://doc.rust-lang.org/std/sync/mpsc/struct.Receiver.html +[`send()`]: https://doc.rust-lang.org/std/sync/mpsc/struct.Sender.html#method.send +[`recv()`]: https://doc.rust-lang.org/std/sync/mpsc/struct.Receiver.html#method.recv +[`mpsc`]: https://doc.rust-lang.org/std/sync/mpsc/index.html diff --git a/src/concurrency/channels/unbounded.md b/src/concurrency/channels/unbounded.md index 05f515ef6c1..fbf9ef7c347 100644 --- a/src/concurrency/channels/unbounded.md +++ b/src/concurrency/channels/unbounded.md @@ -4,7 +4,7 @@ minutes: 2 # Unbounded Channels -You get an unbounded and asynchronous channel with `mpsc::channel()`: +You get an unbounded and asynchronous channel with [`mpsc::channel()`]: ```rust,editable use std::sync::mpsc; @@ -29,3 +29,5 @@ fn main() { } } ``` + +[`mpsc::channel()`]: https://doc.rust-lang.org/std/sync/mpsc/fn.channel.html