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/rand/reader.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/rand/reader.rs')
| -rw-r--r-- | src/libstd/rand/reader.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/libstd/rand/reader.rs b/src/libstd/rand/reader.rs index e19fbd9aaf8..621d70970f0 100644 --- a/src/libstd/rand/reader.rs +++ b/src/libstd/rand/reader.rs @@ -11,7 +11,7 @@ //! A wrapper around any Reader to treat it as an RNG. use container::Container; -use option::{Some, None}; +use result::{Ok, Err}; use io::Reader; use rand::Rng; @@ -49,26 +49,26 @@ impl<R: Reader> Rng for ReaderRng<R> { // platform just involves blitting the bytes into the memory // of the u32, similarly for BE on BE; avoiding byteswapping. if cfg!(target_endian="little") { - self.reader.read_le_u32() + self.reader.read_le_u32().unwrap() } else { - self.reader.read_be_u32() + self.reader.read_be_u32().unwrap() } } fn next_u64(&mut self) -> u64 { // see above for explanation. if cfg!(target_endian="little") { - self.reader.read_le_u64() + self.reader.read_le_u64().unwrap() } else { - self.reader.read_be_u64() + self.reader.read_be_u64().unwrap() } } fn fill_bytes(&mut self, v: &mut [u8]) { if v.len() == 0 { return } match self.reader.read(v) { - Some(n) if n == v.len() => return, - Some(n) => fail!("ReaderRng.fill_bytes could not fill buffer: \ - read {} out of {} bytes.", n, v.len()), - None => fail!("ReaderRng.fill_bytes reached eof.") + Ok(n) if n == v.len() => return, + Ok(n) => fail!("ReaderRng.fill_bytes could not fill buffer: \ + read {} out of {} bytes.", n, v.len()), + Err(e) => fail!("ReaderRng.fill_bytes error: {}", e) } } } |
