Skip to content

Close out #9155 #9697

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 3, 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
22 changes: 9 additions & 13 deletions src/libstd/rt/io/buffered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,25 +187,21 @@ impl<W: Writer> Decorator<W> for BufferedWriter<W> {
}
}

// FIXME #9155 this should be a newtype struct
struct InternalBufferedWriter<W> {
inner: BufferedWriter<W>
}
struct InternalBufferedWriter<W>(BufferedWriter<W>);

impl<W: Reader> Reader for InternalBufferedWriter<W> {
fn read(&mut self, buf: &mut [u8]) -> Option<uint> {
self.inner.inner.read(buf)
self.inner.read(buf)
}

fn eof(&mut self) -> bool {
self.inner.inner.eof()
self.inner.eof()
}
}

/// Wraps a Stream and buffers input and output to and from it
///
/// Note that `BufferedStream` will NOT flush its output buffer when dropped.
// FIXME #9155 this should be a newtype struct
pub struct BufferedStream<S> {
priv inner: BufferedReader<InternalBufferedWriter<S>>
}
Expand All @@ -214,7 +210,7 @@ impl<S: Stream> BufferedStream<S> {
pub fn with_capacities(reader_cap: uint, writer_cap: uint, inner: S)
-> BufferedStream<S> {
let writer = BufferedWriter::with_capacity(writer_cap, inner);
let internal_writer = InternalBufferedWriter { inner: writer };
let internal_writer = InternalBufferedWriter(writer);
let reader = BufferedReader::with_capacity(reader_cap,
internal_writer);
BufferedStream { inner: reader }
Expand All @@ -238,25 +234,25 @@ impl<S: Stream> Reader for BufferedStream<S> {

impl<S: Stream> Writer for BufferedStream<S> {
fn write(&mut self, buf: &[u8]) {
self.inner.inner.inner.write(buf)
self.inner.inner.write(buf)
}

fn flush(&mut self) {
self.inner.inner.inner.flush()
self.inner.inner.flush()
}
}

impl<S: Stream> Decorator<S> for BufferedStream<S> {
fn inner(self) -> S {
self.inner.inner.inner.inner()
self.inner.inner.inner()
}

fn inner_ref<'a>(&'a self) -> &'a S {
self.inner.inner.inner.inner_ref()
self.inner.inner.inner_ref()
}

fn inner_mut_ref<'a>(&'a mut self) -> &'a mut S {
self.inner.inner.inner.inner_mut_ref()
self.inner.inner.inner_mut_ref()
}
}

Expand Down
17 changes: 17 additions & 0 deletions src/test/auxiliary/issue_9155.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

pub struct Foo<T>(T);

impl<T> Foo<T> {
pub fn new(t: T) -> Foo<T> {
Foo(t)
}
}
20 changes: 20 additions & 0 deletions src/test/run-pass/issue_9155.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// aux-build:issue_9155.rs
// xfail-fast windows doesn't like the aux-build

extern mod issue_9155;

struct Baz;

fn main() {
issue_9155::Foo::new(Baz);
}