diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2013-12-21 22:15:04 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-01-15 11:21:56 -0800 |
| commit | adb895a34f6d0b925b8ef877289ca6e3c4d854d4 (patch) | |
| tree | fc5a2b0a6930d08c9b96e4ef24bdf5ff31adc3ec /src/libstd/io | |
| parent | 900893112570eea5a01c0573ae1fa1e3a72397e9 (diff) | |
| download | rust-adb895a34f6d0b925b8ef877289ca6e3c4d854d4.tar.gz rust-adb895a34f6d0b925b8ef877289ca6e3c4d854d4.zip | |
Allow more "error" values in try_recv()
This should allow callers to know whether the channel was empty or disconnected without having to block. Closes #11087
Diffstat (limited to 'src/libstd/io')
| -rw-r--r-- | src/libstd/io/signal.rs | 3 | ||||
| -rw-r--r-- | src/libstd/io/timer.rs | 5 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/libstd/io/signal.rs b/src/libstd/io/signal.rs index 34b4ed5e1ef..0f05254b034 100644 --- a/src/libstd/io/signal.rs +++ b/src/libstd/io/signal.rs @@ -144,6 +144,7 @@ impl Listener { #[cfg(test)] mod test { use libc; + use comm::Empty; use io::timer; use super::{Listener, Interrupt}; @@ -194,7 +195,7 @@ mod test { s2.unregister(Interrupt); sigint(); timer::sleep(10); - assert!(s2.port.try_recv().is_none()); + assert_eq!(s2.port.try_recv(), Empty); } #[cfg(windows)] diff --git a/src/libstd/io/timer.rs b/src/libstd/io/timer.rs index 7c9aa28bfe9..d156a7460e1 100644 --- a/src/libstd/io/timer.rs +++ b/src/libstd/io/timer.rs @@ -123,7 +123,7 @@ mod test { let port1 = timer.oneshot(10000); let port = timer.oneshot(1); port.recv(); - assert_eq!(port1.try_recv(), None); + assert!(port1.recv_opt().is_none()); } #[test] @@ -131,8 +131,7 @@ mod test { let mut timer = Timer::new().unwrap(); let port = timer.oneshot(100000000000); timer.sleep(1); // this should invalidate the port - - assert_eq!(port.try_recv(), None); + assert!(port.recv_opt().is_none()); } #[test] |
