Skip to content

Commit

Permalink
Rewrite Receiver::iter doc example to show resulting values.
Browse files Browse the repository at this point in the history
  • Loading branch information
frewsxcv committed Jun 2, 2017
1 parent 4ed2eda commit d3f3e26
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/libstd/sync/mpsc/mod.rs
Expand Up @@ -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> {
Expand Down

0 comments on commit d3f3e26

Please sign in to comment.