auto merge of #10180 : alexcrichton/rust/flush-default, r=brson

Closes #9126
This commit is contained in:
bors 2013-10-31 02:16:40 -07:00
commit 55eed055cf
14 changed files with 6 additions and 34 deletions

View File

@ -1653,9 +1653,6 @@ impl RtioFileStream for UvFileStream {
let self_ = unsafe { cast::transmute::<&UvFileStream, &mut UvFileStream>(self) };
self_.seek_common(0, SEEK_CUR)
}
fn flush(&mut self) -> Result<(), IoError> {
Ok(())
}
}
pub struct UvProcess {

View File

@ -418,7 +418,6 @@ mod test {
impl rt::io::Writer for S {
fn write(&mut self, _: &[u8]) {}
fn flush(&mut self) {}
}
impl rt::io::Reader for S {

View File

@ -32,8 +32,6 @@ impl<C: GenericChan<~[u8]>> ChanWriter<C> {
impl<C: GenericChan<~[u8]>> Writer for ChanWriter<C> {
fn write(&mut self, _buf: &[u8]) { fail!() }
fn flush(&mut self) { fail!() }
}
struct ReaderPort<R>;

View File

@ -383,15 +383,6 @@ impl Writer for FileStream {
}
}
}
fn flush(&mut self) {
match self.fd.flush() {
Ok(_) => (),
Err(ioerr) => {
io_error::cond.raise(ioerr);
}
}
}
}
/// a `std::rt::io:Seek` trait impl for file I/O.

View File

@ -62,8 +62,6 @@ impl Writer for MemWriter {
// Bump us forward
self.pos += buf.len();
}
fn flush(&mut self) { /* no-op */ }
}
impl Seek for MemWriter {

View File

@ -32,19 +32,16 @@ impl Reader for MockReader {
pub struct MockWriter {
priv write: ~fn(buf: &[u8]),
priv flush: ~fn()
}
impl MockWriter {
pub fn new() -> MockWriter {
MockWriter {
write: |_| (),
flush: || ()
}
}
}
impl Writer for MockWriter {
fn write(&mut self, buf: &[u8]) { (self.write)(buf) }
fn flush(&mut self) { (self.flush)() }
}

View File

@ -810,8 +810,12 @@ pub trait Writer {
/// Raises the `io_error` condition on error
fn write(&mut self, buf: &[u8]);
/// Flush output
fn flush(&mut self);
/// Flush this output stream, ensuring that all intermediately buffered
/// contents reach their destination.
///
/// This is by default a no-op and implementors of the `Writer` trait should
/// decide whether their stream needs to be buffered or not.
fn flush(&mut self) {}
/// Write the result of passing n through `int::to_str_bytes`.
fn write_int(&mut self, n: int) {

View File

@ -132,8 +132,6 @@ impl Writer for FileDesc {
raise_error();
}
}
fn flush(&mut self) {}
}
impl Drop for FileDesc {

View File

@ -84,8 +84,6 @@ impl Writer for TcpStream {
Err(ioerr) => io_error::cond.raise(ioerr),
}
}
fn flush(&mut self) { /* no-op */ }
}
pub struct TcpListener {

View File

@ -100,8 +100,6 @@ impl Writer for UdpStream {
sock.sendto(buf, self.connectedTo);
}
}
fn flush(&mut self) { fail!() }
}
#[cfg(test)]

View File

@ -78,7 +78,6 @@ impl Reader for UnixStream {
impl Writer for UnixStream {
fn write(&mut self, buf: &[u8]) { self.obj.write(buf) }
fn flush(&mut self) { self.obj.flush() }
}
pub struct UnixListener {

View File

@ -86,6 +86,4 @@ impl Writer for PipeStream {
}
}
}
fn flush(&mut self) {}
}

View File

@ -294,8 +294,6 @@ impl Writer for StdWriter {
Err(e) => io_error::cond.raise(e)
}
}
fn flush(&mut self) { /* nothing to do */ }
}
#[cfg(test)]

View File

@ -173,7 +173,6 @@ pub trait RtioFileStream {
fn pwrite(&mut self, buf: &[u8], offset: u64) -> Result<(), IoError>;
fn seek(&mut self, pos: i64, whence: SeekStyle) -> Result<u64, IoError>;
fn tell(&self) -> Result<u64, IoError>;
fn flush(&mut self) -> Result<(), IoError>;
}
pub trait RtioProcess {