commit
6d598989f6
@ -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>>
|
||||
}
|
||||
@ -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 }
|
||||
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
17
src/test/auxiliary/issue_9155.rs
Normal file
17
src/test/auxiliary/issue_9155.rs
Normal file
@ -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
src/test/run-pass/issue_9155.rs
Normal file
20
src/test/run-pass/issue_9155.rs
Normal file
@ -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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user