]> git.lizzy.rs Git - rust.git/commitdiff
Document panic in mpsc::Receiver::recv_timeout
authorFelix Rabe <felix@rabe.io>
Tue, 7 Aug 2018 14:35:03 +0000 (16:35 +0200)
committerGitHub <noreply@github.com>
Tue, 7 Aug 2018 14:35:03 +0000 (16:35 +0200)
src/libstd/sync/mpsc/mod.rs

index fc0e37f150ec95cf4366de99ed3c1c6eab5da065..e82f40ff96fe52852589fe7514a9bd9364b2a705 100644 (file)
@@ -1249,7 +1249,29 @@ pub fn recv(&self) -> Result<T, RecvError> {
     ///
     /// # Panics
     ///
-    /// Panics due to a known issue ([`#39364`][]).
+    /// There is currently a known issue with this function ([`#39364`]) that
+    /// causes `recv_timeout` to panic unexpectedly with the following example:
+    ///
+    /// ```no_run
+    /// use std::sync::mpsc::channel;
+    /// use std::thread;
+    /// use std::time::Duration;
+    /// 
+    /// let (tx, rx) = channel::<String>();
+    ///
+    /// thread::spawn(move || {
+    ///     let d = Duration::from_millis(10);
+    ///     loop {
+    ///         println!("recv");
+    ///         let _r = rx.recv_timeout(d);
+    ///     }
+    /// });
+    ///
+    /// thread::sleep(Duration::from_millis(100));
+    /// let _c1 = tx.clone();
+    ///
+    /// thread::sleep(Duration::from_secs(1));
+    /// ```
     ///
     /// [`#39364`]: https://github.com/rust-lang/rust/issues/39364
     ///