diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-01-29 16:33:57 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-02-03 09:32:33 -0800 |
| commit | ece8a8f520697be50cbe543bebe065c5198dae4d (patch) | |
| tree | fa1bf049d3b5d781c8c56e0d0491a655ece485a2 /src/libstd/io/timer.rs | |
| parent | be4fc638092bf896c5c6c0672136b83b71e491ee (diff) | |
| download | rust-ece8a8f520697be50cbe543bebe065c5198dae4d.tar.gz rust-ece8a8f520697be50cbe543bebe065c5198dae4d.zip | |
std: Remove io::io_error
* All I/O now returns IoResult<T> = Result<T, IoError> * All formatting traits now return fmt::Result = IoResult<()> * The if_ok!() macro was added to libstd
Diffstat (limited to 'src/libstd/io/timer.rs')
| -rw-r--r-- | src/libstd/io/timer.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/libstd/io/timer.rs b/src/libstd/io/timer.rs index 24eaf6adf3f..692aaa7afd0 100644 --- a/src/libstd/io/timer.rs +++ b/src/libstd/io/timer.rs @@ -39,8 +39,8 @@ loop { */ use comm::Port; -use option::Option; use rt::rtio::{IoFactory, LocalIo, RtioTimer}; +use io::IoResult; pub struct Timer { priv obj: ~RtioTimer @@ -48,7 +48,8 @@ pub struct Timer { /// Sleep the current task for `msecs` milliseconds. pub fn sleep(msecs: u64) { - let mut timer = Timer::new().expect("timer::sleep: could not create a Timer"); + let timer = Timer::new(); + let mut timer = timer.ok().expect("timer::sleep: could not create a Timer"); timer.sleep(msecs) } @@ -57,7 +58,7 @@ impl Timer { /// Creates a new timer which can be used to put the current task to sleep /// for a number of milliseconds, or to possibly create channels which will /// get notified after an amount of time has passed. - pub fn new() -> Option<Timer> { + pub fn new() -> IoResult<Timer> { LocalIo::maybe_raise(|io| io.timer_init().map(|t| Timer { obj: t })) } |
