Add links and some examples to std::sync::mpsc docs#40981
Add links and some examples to std::sync::mpsc docs#40981bors merged 5 commits intorust-lang:masterfrom
Conversation
This change adds links to to `Receiver`, `Iter`, `TryIter`, `IntoIter`, `Sender`, `SyncSender`, `SendError`, `RecvError`, `TryRecvError`, `RecvTimeoutError`, `TrySendError`, `Sender::send`, `SyncSender::send`, `SyncSender::try_send`, `Receiver::recv`, `Receiver::recv_timeout`, `Receiver::iter`, and `Receiver::try_iter`. Examples added to `Receiver`, `Sender`, `Receiver::iter`.
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
|
Travis found some errors https://gist.github.com/frewsxcv/d968eb5970f2d7530fc6c86c723c95a5 |
steveklabnik
left a comment
There was a problem hiding this comment.
Thank you so much! This is great, I just have a few minor style nits. We don't use ()s for function names, and some extra whitespace will make these examples more readable. Thank you!
src/libstd/sync/mpsc/mod.rs
Outdated
| //! These channels come in two flavors: | ||
| //! | ||
| //! 1. An asynchronous, infinitely buffered channel. The `channel()` function | ||
| //! 1. An asynchronous, infinitely buffered channel. The [`channel()`] function |
There was a problem hiding this comment.
I know you're adapting existing text here, but the style is to drop the ()s. Would you mind doing that as well please?
src/libstd/sync/mpsc/mod.rs
Outdated
| //! 2. A synchronous, bounded channel. The `sync_channel()` function will return | ||
| //! a `(SyncSender, Receiver)` tuple where the storage for pending messages | ||
| //! is a pre-allocated buffer of a fixed size. All sends will be | ||
| //! 2. A synchronous, bounded channel. The [`sync_channel()`] function will |
src/libstd/sync/mpsc/mod.rs
Outdated
| //! [`Receiver`]: ../../../std/sync/mpsc/struct.Receiver.html | ||
| //! [`send`]: ../../../std/sync/mpsc/struct.Sender.html#method.send | ||
| //! [`channel()`]: ../../../std/sync/mpsc/fn.channel.html | ||
| //! [`sync_channel()`]: ../../../std/sync/mpsc/fn.sync_channel.html |
There was a problem hiding this comment.
and both of these lines to match
src/libstd/sync/mpsc/mod.rs
Outdated
| //! continue to `unwrap()` the results returned from this module, instigating a | ||
| //! propagation of failure among threads if one unexpectedly dies. | ||
| //! continue to make progress, so [`Err`] will be returned. Many applications | ||
| //! will continue to [`unwrap()`] the results returned from this module, |
src/libstd/sync/mpsc/mod.rs
Outdated
| //! | ||
| //! [`Result`]: ../../../std/result/enum.Result.html | ||
| //! [`Err`]: ../../../std/result/enum.Result.html#variant.Err | ||
| //! [`unwrap()`]: ../../../std/result/enum.Result.html#method.unwrap |
| /// thread::spawn(move || { | ||
| /// sender.send(1).unwrap(); | ||
| /// }); | ||
| /// // Second thread owns sender2 |
| /// thread::spawn(move || { | ||
| /// sender2.send(2).unwrap(); | ||
| /// }); | ||
| /// let msg = receiver.recv().unwrap(); |
| /// }); | ||
| /// let msg = receiver.recv().unwrap(); | ||
| /// let msg2 = receiver.recv().unwrap(); | ||
| /// assert_eq!(3, msg + msg2); |
There was a problem hiding this comment.
and one above here, please!
| /// ```rust | ||
| /// use std::sync::mpsc::channel; | ||
| /// use std::thread; | ||
| /// let (send, recv) = channel(); |
There was a problem hiding this comment.
one blank line above and below this line, please!
| /// send.send(2u8).unwrap(); | ||
| /// send.send(3u8).unwrap(); | ||
| /// }); | ||
| /// for x in recv.iter() { |
|
@bors: r+ rollup Thanks! |
|
📌 Commit ab4f442 has been approved by |
Add links and some examples to std::sync::mpsc docs Addresses part of rust-lang#29377 r? @steveklabnik I took a stab at adding links to the `std::sync::mpsc` docs, and I also wrote a few examples. Edit: Whoops, typed in `?r` instead of `r?`.
Add links and some examples to std::sync::mpsc docs Addresses part of rust-lang#29377 r? @steveklabnik I took a stab at adding links to the `std::sync::mpsc` docs, and I also wrote a few examples. Edit: Whoops, typed in `?r` instead of `r?`.
Add links and some examples to std::sync::mpsc docs Addresses part of rust-lang#29377 r? @steveklabnik I took a stab at adding links to the `std::sync::mpsc` docs, and I also wrote a few examples. Edit: Whoops, typed in `?r` instead of `r?`.
Add links and some examples to std::sync::mpsc docs Addresses part of rust-lang#29377 r? @steveklabnik I took a stab at adding links to the `std::sync::mpsc` docs, and I also wrote a few examples. Edit: Whoops, typed in `?r` instead of `r?`.
Addresses part of #29377
r? @steveklabnik
I took a stab at adding links to the
std::sync::mpscdocs, and I also wrote a few examples.Edit: Whoops, typed in
?rinstead ofr?.