]> git.lizzy.rs Git - rust.git/commitdiff
std: Fix a doc example on io::signal
authorAlex Crichton <alex@alexcrichton.com>
Sun, 6 Apr 2014 04:02:35 +0000 (21:02 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Sun, 6 Apr 2014 05:13:32 +0000 (22:13 -0700)
This also makes the listener struct sendable again by explicitly putting the
Send bound on the relevant Rtio object.

cc #13352

src/libstd/io/signal.rs

index 494cc6f6b02d4c9c7565d07567b0b4067bd775cb..6762e7c6a76ef22a43789d8954f2dc016fbfeac7 100644 (file)
@@ -23,6 +23,7 @@
 use comm::{Sender, Receiver, channel};
 use io;
 use iter::Iterator;
+use kinds::Send;
 use mem::drop;
 use option::{Some, None};
 use result::{Ok, Err};
@@ -63,25 +64,23 @@ pub enum Signum {
 ///
 /// # Example
 ///
-/// ```rust,ignore
+/// ```rust,no_run
+/// # #![allow(unused_must_use)]
 /// use std::io::signal::{Listener, Interrupt};
 ///
 /// let mut listener = Listener::new();
 /// listener.register(Interrupt);
 ///
-/// spawn({
-///     loop {
-///         match listener.rx.recv() {
-///             Interrupt => println!("Got Interrupt'ed"),
-///             _ => (),
-///         }
+/// loop {
+///     match listener.rx.recv() {
+///         Interrupt => println!("Got Interrupt'ed"),
+///         _ => (),
 ///     }
-/// });
-///
+/// }
 /// ```
 pub struct Listener {
     /// A map from signums to handles to keep the handles in memory
-    handles: ~[(Signum, ~RtioSignal)],
+    handles: ~[(Signum, ~RtioSignal:Send)],
     /// This is where all the handles send signums, which are received by
     /// the clients from the receiver.
     tx: Sender<Signum>,