Document panic in mpsc::Receiver::recv_timeout

This commit is contained in:
Felix Rabe 2018-08-07 16:35:03 +02:00 committed by GitHub
parent c3fdd19e43
commit b1f47aa838
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1249,7 +1249,29 @@ impl<T> Receiver<T> {
///
/// # 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
///