From c6fa4e277f5eb873e979d8ac1ae7a4c3ccb1e9cc Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 15 Oct 2013 20:55:50 -0700 Subject: [PATCH] Address a few XXX comments throughout the runtime * Implement Seek for Option * Remove outdated comment for io::process * De-pub a component which didn't need to be pub --- src/libstd/rt/io/mod.rs | 3 +-- src/libstd/rt/io/option.rs | 22 +++++++++++++++++++--- src/libstd/rt/io/process.rs | 7 ------- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/libstd/rt/io/mod.rs b/src/libstd/rt/io/mod.rs index a80c1aab398..a703f9885ac 100644 --- a/src/libstd/rt/io/mod.rs +++ b/src/libstd/rt/io/mod.rs @@ -332,8 +332,7 @@ pub mod native { mod mock; /// The default buffer size for various I/O operations -/// XXX: Not pub -pub static DEFAULT_BUF_SIZE: uint = 1024 * 64; +static DEFAULT_BUF_SIZE: uint = 1024 * 64; /// The type passed to I/O condition handlers to indicate error /// diff --git a/src/libstd/rt/io/option.rs b/src/libstd/rt/io/option.rs index 2ea1b615483..ecfc4a832bf 100644 --- a/src/libstd/rt/io/option.rs +++ b/src/libstd/rt/io/option.rs @@ -13,11 +13,9 @@ //! I/O constructors return option types to allow errors to be handled. //! These implementations allow e.g. `Option` to be used //! as a `Reader` without unwrapping the option first. -//! -//! # XXX Seek and Close use option::*; -use super::{Reader, Writer, Listener, Acceptor}; +use super::{Reader, Writer, Listener, Acceptor, Seek, SeekStyle}; use super::{standard_error, PreviousIoError, io_error, read_error, IoError}; fn prev_io_error() -> IoError { @@ -62,6 +60,24 @@ impl Reader for Option { } } +impl Seek for Option { + fn tell(&self) -> u64 { + match *self { + Some(ref seeker) => seeker.tell(), + None => { + io_error::cond.raise(prev_io_error()); + 0 + } + } + } + fn seek(&mut self, pos: i64, style: SeekStyle) { + match *self { + Some(ref mut seeker) => seeker.seek(pos, style), + None => io_error::cond.raise(prev_io_error()) + } + } +} + impl, L: Listener> Listener for Option { fn listen(self) -> Option { match self { diff --git a/src/libstd/rt/io/process.rs b/src/libstd/rt/io/process.rs index e0ffa82b59f..0da9c2166b1 100644 --- a/src/libstd/rt/io/process.rs +++ b/src/libstd/rt/io/process.rs @@ -70,13 +70,6 @@ pub enum StdioContainer { /// specified for. InheritFd(libc::c_int), - // XXX: these two shouldn't have libuv-specific implementation details - - /// The specified libuv stream is inherited for the corresponding file - /// descriptor it is assigned to. - // XXX: this needs to be thought out more. - //InheritStream(uv::net::StreamWatcher), - /// Creates a pipe for the specified file descriptor which will be directed /// into the previously-initialized pipe passed in. ///