Skip to content

Commit 6d59898

Browse files
committed
Merge pull request #9697 from sfackler/issue_9155
Close out #9155
2 parents 8f40641 + 435ca16 commit 6d59898

File tree

3 files changed

+46
-13
lines changed

3 files changed

+46
-13
lines changed

src/libstd/rt/io/buffered.rs

+9-13
Original file line numberDiff line numberDiff line change
@@ -187,25 +187,21 @@ impl<W: Writer> Decorator<W> for BufferedWriter<W> {
187187
}
188188
}
189189

190-
// FIXME #9155 this should be a newtype struct
191-
struct InternalBufferedWriter<W> {
192-
inner: BufferedWriter<W>
193-
}
190+
struct InternalBufferedWriter<W>(BufferedWriter<W>);
194191

195192
impl<W: Reader> Reader for InternalBufferedWriter<W> {
196193
fn read(&mut self, buf: &mut [u8]) -> Option<uint> {
197-
self.inner.inner.read(buf)
194+
self.inner.read(buf)
198195
}
199196

200197
fn eof(&mut self) -> bool {
201-
self.inner.inner.eof()
198+
self.inner.eof()
202199
}
203200
}
204201

205202
/// Wraps a Stream and buffers input and output to and from it
206203
///
207204
/// Note that `BufferedStream` will NOT flush its output buffer when dropped.
208-
// FIXME #9155 this should be a newtype struct
209205
pub struct BufferedStream<S> {
210206
priv inner: BufferedReader<InternalBufferedWriter<S>>
211207
}
@@ -214,7 +210,7 @@ impl<S: Stream> BufferedStream<S> {
214210
pub fn with_capacities(reader_cap: uint, writer_cap: uint, inner: S)
215211
-> BufferedStream<S> {
216212
let writer = BufferedWriter::with_capacity(writer_cap, inner);
217-
let internal_writer = InternalBufferedWriter { inner: writer };
213+
let internal_writer = InternalBufferedWriter(writer);
218214
let reader = BufferedReader::with_capacity(reader_cap,
219215
internal_writer);
220216
BufferedStream { inner: reader }
@@ -238,25 +234,25 @@ impl<S: Stream> Reader for BufferedStream<S> {
238234

239235
impl<S: Stream> Writer for BufferedStream<S> {
240236
fn write(&mut self, buf: &[u8]) {
241-
self.inner.inner.inner.write(buf)
237+
self.inner.inner.write(buf)
242238
}
243239

244240
fn flush(&mut self) {
245-
self.inner.inner.inner.flush()
241+
self.inner.inner.flush()
246242
}
247243
}
248244

249245
impl<S: Stream> Decorator<S> for BufferedStream<S> {
250246
fn inner(self) -> S {
251-
self.inner.inner.inner.inner()
247+
self.inner.inner.inner()
252248
}
253249

254250
fn inner_ref<'a>(&'a self) -> &'a S {
255-
self.inner.inner.inner.inner_ref()
251+
self.inner.inner.inner_ref()
256252
}
257253

258254
fn inner_mut_ref<'a>(&'a mut self) -> &'a mut S {
259-
self.inner.inner.inner.inner_mut_ref()
255+
self.inner.inner.inner_mut_ref()
260256
}
261257
}
262258

src/test/auxiliary/issue_9155.rs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
pub struct Foo<T>(T);
12+
13+
impl<T> Foo<T> {
14+
pub fn new(t: T) -> Foo<T> {
15+
Foo(t)
16+
}
17+
}

src/test/run-pass/issue_9155.rs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// aux-build:issue_9155.rs
12+
// xfail-fast windows doesn't like the aux-build
13+
14+
extern mod issue_9155;
15+
16+
struct Baz;
17+
18+
fn main() {
19+
issue_9155::Foo::new(Baz);
20+
}

0 commit comments

Comments
 (0)