Skip to content

Commit e026b75

Browse files
authored
Merge pull request #703 from spacekookie/recv-docs
channel/recv: improving function docs and code example
2 parents 51dd7ce + aae835c commit e026b75

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Diff for: src/sync/channel.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,9 @@ pub struct Receiver<T> {
346346
impl<T> Receiver<T> {
347347
/// Receives a message from the channel.
348348
///
349-
/// If the channel is empty and still has senders, this method will wait until a message is
350-
/// sent into the channel or until all senders get dropped.
349+
/// If the channel is emtpy and still has senders, this method
350+
/// will wait until a message is sent into it. Once all senders
351+
/// have been dropped it will return `None`.
351352
///
352353
/// # Examples
353354
///
@@ -362,10 +363,13 @@ impl<T> Receiver<T> {
362363
/// task::spawn(async move {
363364
/// s.send(1).await;
364365
/// s.send(2).await;
366+
/// // Then we drop the sender
365367
/// });
366368
///
367369
/// assert_eq!(r.recv().await, Some(1));
368370
/// assert_eq!(r.recv().await, Some(2));
371+
///
372+
/// // recv() returns `None`
369373
/// assert_eq!(r.recv().await, None);
370374
/// #
371375
/// # })

0 commit comments

Comments
 (0)