about summary refs log tree commit diff
path: root/src/libstd/sync
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-06-02 22:19:08 +0000
committerbors <bors@rust-lang.org>2017-06-02 22:19:08 +0000
commitbb907adbbd1727938245a67db1c92be7e4dec3e6 (patch)
treea6229fb68940fbe7bd2c7fae09b92fa10500c81d /src/libstd/sync
parent107bd67ef7fb3e8027d7234d687cdd27c3efaa0d (diff)
parente05f1c12901e26f75a92f441f636942a8a3bf7c1 (diff)
downloadrust-bb907adbbd1727938245a67db1c92be7e4dec3e6.tar.gz
rust-bb907adbbd1727938245a67db1c92be7e4dec3e6.zip
Auto merge of #42381 - Mark-Simulacrum:rollup, r=Mark-Simulacrum
Rollup of 10 pull requests

- Successful merges: #41981, #42225, #42310, #42319, #42335, #42343, #42355, #42360, #42370, #42372
- Failed merges:
Diffstat (limited to 'src/libstd/sync')
-rw-r--r--src/libstd/sync/mpsc/mod.rs35
1 files changed, 21 insertions, 14 deletions
diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs
index 40b3e789ce4..7d5e1929cd2 100644
--- a/src/libstd/sync/mpsc/mod.rs
+++ b/src/libstd/sync/mpsc/mod.rs
@@ -1370,14 +1370,16 @@ impl<T> Receiver<T> {
     /// let (send, recv) = channel();
     ///
     /// thread::spawn(move || {
-    ///     send.send(1u8).unwrap();
-    ///     send.send(2u8).unwrap();
-    ///     send.send(3u8).unwrap();
+    ///     send.send(1).unwrap();
+    ///     send.send(2).unwrap();
+    ///     send.send(3).unwrap();
     /// });
     ///
-    /// for x in recv.iter() {
-    ///     println!("Got: {}", x);
-    /// }
+    /// let mut iter = recv.iter();
+    /// assert_eq!(iter.next(), Some(1));
+    /// assert_eq!(iter.next(), Some(2));
+    /// assert_eq!(iter.next(), Some(3));
+    /// assert_eq!(iter.next(), None);
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn iter(&self) -> Iter<T> {
@@ -1393,29 +1395,34 @@ impl<T> Receiver<T> {
     ///
     /// # Examples
     ///
-    /// ```rust
+    /// ```no_run
     /// use std::sync::mpsc::channel;
     /// use std::thread;
     /// use std::time::Duration;
     ///
     /// let (sender, receiver) = channel();
     ///
-    /// // Nothing is in the buffer yet
+    /// // nothing is in the buffer yet
     /// assert!(receiver.try_iter().next().is_none());
-    /// println!("Nothing in the buffer...");
     ///
     /// thread::spawn(move || {
+    ///     thread::sleep(Duration::from_secs(1));
     ///     sender.send(1).unwrap();
     ///     sender.send(2).unwrap();
     ///     sender.send(3).unwrap();
     /// });
     ///
-    /// println!("Going to sleep...");
-    /// thread::sleep(Duration::from_secs(2)); // block for two seconds
+    /// // nothing is in the buffer yet
+    /// assert!(receiver.try_iter().next().is_none());
+    ///
+    /// // block for two seconds
+    /// thread::sleep(Duration::from_secs(2));
     ///
-    /// for x in receiver.try_iter() {
-    ///     println!("Got: {}", x);
-    /// }
+    /// let mut iter = receiver.try_iter();
+    /// assert_eq!(iter.next(), Some(1));
+    /// assert_eq!(iter.next(), Some(2));
+    /// assert_eq!(iter.next(), Some(3));
+    /// assert_eq!(iter.next(), None);
     /// ```
     #[stable(feature = "receiver_try_iter", since = "1.15.0")]
     pub fn try_iter(&self) -> TryIter<T> {