Skip to content

Make Writer::flush a no-op default method #10180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 31, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/librustuv/uvio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion src/libstd/rt/io/buffered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 0 additions & 2 deletions src/libstd/rt/io/comm_adapters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
Expand Down
9 changes: 0 additions & 9 deletions src/libstd/rt/io/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 0 additions & 2 deletions src/libstd/rt/io/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 0 additions & 3 deletions src/libstd/rt/io/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)() }
}
8 changes: 6 additions & 2 deletions src/libstd/rt/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 0 additions & 2 deletions src/libstd/rt/io/native/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ impl Writer for FileDesc {
raise_error();
}
}

fn flush(&mut self) {}
}

impl Drop for FileDesc {
Expand Down
2 changes: 0 additions & 2 deletions src/libstd/rt/io/net/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ impl Writer for TcpStream {
Err(ioerr) => io_error::cond.raise(ioerr),
}
}

fn flush(&mut self) { /* no-op */ }
}

pub struct TcpListener {
Expand Down
2 changes: 0 additions & 2 deletions src/libstd/rt/io/net/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ impl Writer for UdpStream {
sock.sendto(buf, self.connectedTo);
}
}

fn flush(&mut self) { fail!() }
}

#[cfg(test)]
Expand Down
1 change: 0 additions & 1 deletion src/libstd/rt/io/net/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 0 additions & 2 deletions src/libstd/rt/io/pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,4 @@ impl Writer for PipeStream {
}
}
}

fn flush(&mut self) {}
}
2 changes: 0 additions & 2 deletions src/libstd/rt/io/stdio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,6 @@ impl Writer for StdWriter {
Err(e) => io_error::cond.raise(e)
}
}

fn flush(&mut self) { /* nothing to do */ }
}

#[cfg(test)]
Expand Down
1 change: 0 additions & 1 deletion src/libstd/rt/rtio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down