1
- // ignore-tidy-filelength
2
-
3
1
//! Multi-producer, single-consumer FIFO queue communication primitives.
4
2
//!
5
3
//! This module provides message-based communication over channels, concretely
27
25
//! that a bound of 0 is allowed, causing the channel to become a "rendezvous"
28
26
//! channel where each sender atomically hands off a message to a receiver.
29
27
//!
30
- //! [`Sender`]: ../../../std/sync/mpsc/struct.Sender.html
31
- //! [`SyncSender`]: ../../../std/sync/mpsc/struct.SyncSender.html
32
- //! [`Receiver`]: ../../../std/sync/mpsc/struct.Receiver.html
33
- //! [`send`]: ../../../std/sync/mpsc/struct.Sender.html#method.send
34
- //! [`channel`]: ../../../std/sync/mpsc/fn.channel.html
35
- //! [`sync_channel`]: ../../../std/sync/mpsc/fn.sync_channel.html
28
+ //! [`send`]: Sender::send
36
29
//!
37
30
//! ## Disconnection
38
31
//!
46
39
//! will continue to [`unwrap`] the results returned from this module,
47
40
//! instigating a propagation of failure among threads if one unexpectedly dies.
48
41
//!
49
- //! [`Result`]: ../../../std/result/enum.Result.html
50
- //! [`Err`]: ../../../std/result/enum.Result.html#variant.Err
51
- //! [`unwrap`]: ../../../std/result/enum.Result.html#method.unwrap
42
+ //! [`unwrap`]: Result::unwrap
52
43
//!
53
44
//! # Examples
54
45
//!
@@ -291,9 +282,7 @@ mod cache_aligned;
291
282
///
292
283
/// Messages sent to the channel can be retrieved using [`recv`].
293
284
///
294
- /// [`channel`]: fn.channel.html
295
- /// [`sync_channel`]: fn.sync_channel.html
296
- /// [`recv`]: struct.Receiver.html#method.recv
285
+ /// [`recv`]: Receiver::recv
297
286
///
298
287
/// # Examples
299
288
///
@@ -333,10 +322,8 @@ impl<T> !Sync for Receiver<T> {}
333
322
/// waiting for a new message, and [`None`] will be returned
334
323
/// when the corresponding channel has hung up.
335
324
///
336
- /// [`iter`]: struct.Receiver.html#method.iter
337
- /// [`Receiver`]: struct.Receiver.html
338
- /// [`next`]: ../../../std/iter/trait.Iterator.html#tymethod.next
339
- /// [`None`]: ../../../std/option/enum.Option.html#variant.None
325
+ /// [`iter`]: Receiver::iter
326
+ /// [`next`]: Iterator::next
340
327
///
341
328
/// # Examples
342
329
///
@@ -371,9 +358,7 @@ pub struct Iter<'a, T: 'a> {
371
358
/// This iterator will never block the caller in order to wait for data to
372
359
/// become available. Instead, it will return [`None`].
373
360
///
374
- /// [`Receiver`]: struct.Receiver.html
375
- /// [`try_iter`]: struct.Receiver.html#method.try_iter
376
- /// [`None`]: ../../../std/option/enum.Option.html#variant.None
361
+ /// [`try_iter`]: Receiver::try_iter
377
362
///
378
363
/// # Examples
379
364
///
@@ -414,9 +399,7 @@ pub struct TryIter<'a, T: 'a> {
414
399
/// is called, waiting for a new message, and [`None`] will be
415
400
/// returned if the corresponding channel has hung up.
416
401
///
417
- /// [`Receiver`]: struct.Receiver.html
418
- /// [`next`]: ../../../std/iter/trait.Iterator.html#tymethod.next
419
- /// [`None`]: ../../../std/option/enum.Option.html#variant.None
402
+ /// [`next`]: Iterator::next
420
403
///
421
404
/// # Examples
422
405
///
@@ -447,8 +430,7 @@ pub struct IntoIter<T> {
447
430
///
448
431
/// Messages can be sent through this channel with [`send`].
449
432
///
450
- /// [`channel`]: fn.channel.html
451
- /// [`send`]: struct.Sender.html#method.send
433
+ /// [`send`]: Sender::send
452
434
///
453
435
/// # Examples
454
436
///
@@ -493,9 +475,8 @@ impl<T> !Sync for Sender<T> {}
493
475
///
494
476
/// [`send`] will block if there is no space in the internal buffer.
495
477
///
496
- /// [`sync_channel`]: fn.sync_channel.html
497
- /// [`send`]: struct.SyncSender.html#method.send
498
- /// [`try_send`]: struct.SyncSender.html#method.try_send
478
+ /// [`send`]: SyncSender::send
479
+ /// [`try_send`]: SyncSender::try_send
499
480
///
500
481
/// # Examples
501
482
///
@@ -549,8 +530,8 @@ unsafe impl<T: Send> Send for SyncSender<T> {}
549
530
/// disconnected, implying that the data could never be received. The error
550
531
/// contains the data being sent as a payload so it can be recovered.
551
532
///
552
- /// [`Sender::send`]: struct. Sender.html#method. send
553
- /// [`SyncSender::send`]: struct. SyncSender.html#method. send
533
+ /// [`Sender::send`]: Sender:: send
534
+ /// [`SyncSender::send`]: SyncSender:: send
554
535
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
555
536
#[ derive( PartialEq , Eq , Clone , Copy ) ]
556
537
pub struct SendError < T > ( #[ stable( feature = "rust1" , since = "1.0.0" ) ] pub T ) ;
@@ -561,10 +542,7 @@ pub struct SendError<T>(#[stable(feature = "rust1", since = "1.0.0")] pub T);
561
542
/// [`channel`] (or [`sync_channel`]) is disconnected, implying that no further
562
543
/// messages will ever be received.
563
544
///
564
- /// [`recv`]: struct.Receiver.html#method.recv
565
- /// [`Receiver`]: struct.Receiver.html
566
- /// [`channel`]: fn.channel.html
567
- /// [`sync_channel`]: fn.sync_channel.html
545
+ /// [`recv`]: Receiver::recv
568
546
#[ derive( PartialEq , Eq , Clone , Copy , Debug ) ]
569
547
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
570
548
pub struct RecvError ;
@@ -573,9 +551,7 @@ pub struct RecvError;
573
551
/// not return data when called. This can occur with both a [`channel`] and
574
552
/// a [`sync_channel`].
575
553
///
576
- /// [`try_recv`]: struct.Receiver.html#method.try_recv
577
- /// [`channel`]: fn.channel.html
578
- /// [`sync_channel`]: fn.sync_channel.html
554
+ /// [`try_recv`]: Receiver::try_recv
579
555
#[ derive( PartialEq , Eq , Clone , Copy , Debug ) ]
580
556
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
581
557
pub enum TryRecvError {
@@ -594,9 +570,7 @@ pub enum TryRecvError {
594
570
/// unable to return data when called. This can occur with both a [`channel`] and
595
571
/// a [`sync_channel`].
596
572
///
597
- /// [`recv_timeout`]: struct.Receiver.html#method.recv_timeout
598
- /// [`channel`]: fn.channel.html
599
- /// [`sync_channel`]: fn.sync_channel.html
573
+ /// [`recv_timeout`]: Receiver::recv_timeout
600
574
#[ derive( PartialEq , Eq , Clone , Copy , Debug ) ]
601
575
#[ stable( feature = "mpsc_recv_timeout" , since = "1.12.0" ) ]
602
576
pub enum RecvTimeoutError {
@@ -613,7 +587,7 @@ pub enum RecvTimeoutError {
613
587
/// This enumeration is the list of the possible error outcomes for the
614
588
/// [`try_send`] method.
615
589
///
616
- /// [`try_send`]: struct. SyncSender.html#method. try_send
590
+ /// [`try_send`]: SyncSender:: try_send
617
591
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
618
592
#[ derive( PartialEq , Eq , Clone , Copy ) ]
619
593
pub enum TrySendError < T > {
@@ -623,16 +597,11 @@ pub enum TrySendError<T> {
623
597
/// If this is a buffered channel, then the buffer is full at this time. If
624
598
/// this is not a buffered channel, then there is no [`Receiver`] available to
625
599
/// acquire the data.
626
- ///
627
- /// [`sync_channel`]: fn.sync_channel.html
628
- /// [`Receiver`]: struct.Receiver.html
629
600
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
630
601
Full ( #[ stable( feature = "rust1" , since = "1.0.0" ) ] T ) ,
631
602
632
603
/// This [`sync_channel`]'s receiving half has disconnected, so the data could not be
633
604
/// sent. The data is returned back to the callee in this case.
634
- ///
635
- /// [`sync_channel`]: fn.sync_channel.html
636
605
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
637
606
Disconnected ( #[ stable( feature = "rust1" , since = "1.0.0" ) ] T ) ,
638
607
}
@@ -680,13 +649,8 @@ impl<T> UnsafeFlavor<T> for Receiver<T> {
680
649
/// [`Sender`] is disconnected while trying to [`recv`], the [`recv`] method will
681
650
/// return a [`RecvError`].
682
651
///
683
- /// [`send`]: struct.Sender.html#method.send
684
- /// [`recv`]: struct.Receiver.html#method.recv
685
- /// [`Sender`]: struct.Sender.html
686
- /// [`Receiver`]: struct.Receiver.html
687
- /// [`sync_channel`]: fn.sync_channel.html
688
- /// [`SendError`]: struct.SendError.html
689
- /// [`RecvError`]: struct.RecvError.html
652
+ /// [`send`]: Sender::send
653
+ /// [`recv`]: Receiver::recv
690
654
///
691
655
/// # Examples
692
656
///
@@ -733,13 +697,8 @@ pub fn channel<T>() -> (Sender<T>, Receiver<T>) {
733
697
/// [`SendError`]. Similarly, If the [`SyncSender`] is disconnected while trying
734
698
/// to [`recv`], the [`recv`] method will return a [`RecvError`].
735
699
///
736
- /// [`channel`]: fn.channel.html
737
- /// [`send`]: struct.SyncSender.html#method.send
738
- /// [`recv`]: struct.Receiver.html#method.recv
739
- /// [`SyncSender`]: struct.SyncSender.html
740
- /// [`Receiver`]: struct.Receiver.html
741
- /// [`SendError`]: struct.SendError.html
742
- /// [`RecvError`]: struct.RecvError.html
700
+ /// [`send`]: SyncSender::send
701
+ /// [`recv`]: Receiver::recv
743
702
///
744
703
/// # Examples
745
704
///
@@ -786,9 +745,6 @@ impl<T> Sender<T> {
786
745
/// will be received. It is possible for the corresponding receiver to
787
746
/// hang up immediately after this function returns [`Ok`].
788
747
///
789
- /// [`Err`]: ../../../std/result/enum.Result.html#variant.Err
790
- /// [`Ok`]: ../../../std/result/enum.Result.html#variant.Ok
791
- ///
792
748
/// This method will never block the current thread.
793
749
///
794
750
/// # Examples
@@ -933,9 +889,6 @@ impl<T> SyncSender<T> {
933
889
/// [`Receiver`] has disconnected and is no longer able to receive
934
890
/// information.
935
891
///
936
- /// [`Err`]: ../../../std/result/enum.Result.html#variant.Err
937
- /// [`Receiver`]: ../../../std/sync/mpsc/struct.Receiver.html
938
- ///
939
892
/// # Examples
940
893
///
941
894
/// ```rust
@@ -971,7 +924,7 @@ impl<T> SyncSender<T> {
971
924
/// See [`send`] for notes about guarantees of whether the
972
925
/// receiver has received the data or not if this function is successful.
973
926
///
974
- /// [`send`]: ../../../std/sync/mpsc/struct.SyncSender.html#method. send
927
+ /// [`send`]: Self:: send
975
928
///
976
929
/// # Examples
977
930
///
@@ -1059,7 +1012,7 @@ impl<T> Receiver<T> {
1059
1012
/// Compared with [`recv`], this function has two failure cases instead of one
1060
1013
/// (one for disconnection, one for an empty buffer).
1061
1014
///
1062
- /// [`recv`]: struct.Receiver.html#method. recv
1015
+ /// [`recv`]: Self:: recv
1063
1016
///
1064
1017
/// # Examples
1065
1018
///
@@ -1117,10 +1070,6 @@ impl<T> Receiver<T> {
1117
1070
/// However, since channels are buffered, messages sent before the disconnect
1118
1071
/// will still be properly received.
1119
1072
///
1120
- /// [`Sender`]: struct.Sender.html
1121
- /// [`SyncSender`]: struct.SyncSender.html
1122
- /// [`Err`]: ../../../std/result/enum.Result.html#variant.Err
1123
- ///
1124
1073
/// # Examples
1125
1074
///
1126
1075
/// ```
@@ -1203,10 +1152,6 @@ impl<T> Receiver<T> {
1203
1152
/// However, since channels are buffered, messages sent before the disconnect
1204
1153
/// will still be properly received.
1205
1154
///
1206
- /// [`Sender`]: struct.Sender.html
1207
- /// [`SyncSender`]: struct.SyncSender.html
1208
- /// [`Err`]: ../../../std/result/enum.Result.html#variant.Err
1209
- ///
1210
1155
/// # Known Issues
1211
1156
///
1212
1157
/// There is currently a known issue (see [`#39364`]) that causes `recv_timeout`
@@ -1304,10 +1249,6 @@ impl<T> Receiver<T> {
1304
1249
/// However, since channels are buffered, messages sent before the disconnect
1305
1250
/// will still be properly received.
1306
1251
///
1307
- /// [`Sender`]: struct.Sender.html
1308
- /// [`SyncSender`]: struct.SyncSender.html
1309
- /// [`Err`]: ../../../std/result/enum.Result.html#variant.Err
1310
- ///
1311
1252
/// # Examples
1312
1253
///
1313
1254
/// Successfully receiving value before reaching deadline:
@@ -1397,9 +1338,6 @@ impl<T> Receiver<T> {
1397
1338
/// Returns an iterator that will block waiting for messages, but never
1398
1339
/// [`panic!`]. It will return [`None`] when the channel has hung up.
1399
1340
///
1400
- /// [`panic!`]: ../../../std/macro.panic.html
1401
- /// [`None`]: ../../../std/option/enum.Option.html#variant.None
1402
- ///
1403
1341
/// # Examples
1404
1342
///
1405
1343
/// ```rust
@@ -1430,8 +1368,6 @@ impl<T> Receiver<T> {
1430
1368
/// channel has hung up. The iterator will never [`panic!`] or block the
1431
1369
/// user by waiting for values.
1432
1370
///
1433
- /// [`panic!`]: ../../../std/macro.panic.html
1434
- ///
1435
1371
/// # Examples
1436
1372
///
1437
1373
/// ```no_run
0 commit comments