about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorSteven Fackler <sfackler@gmail.com>2013-10-03 00:15:54 -0700
committerSteven Fackler <sfackler@gmail.com>2013-10-03 00:15:54 -0700
commit435ca16f4fa7bd47c16de693054be5cba5fd4ebb (patch)
treef03e768b9ca00cbd0b0e004b86f68a8a24f619aa /src
parentb637798a5aa7878daa57c147028e98f2c5bc03c5 (diff)
downloadrust-435ca16f4fa7bd47c16de693054be5cba5fd4ebb.tar.gz
rust-435ca16f4fa7bd47c16de693054be5cba5fd4ebb.zip
Close out #9155
Add a test to make sure it works and switch a private struct over to a
newtype.

Closes #9155
Diffstat (limited to 'src')
-rw-r--r--src/libstd/rt/io/buffered.rs22
-rw-r--r--src/test/auxiliary/issue_9155.rs17
-rw-r--r--src/test/run-pass/issue_9155.rs20
3 files changed, 46 insertions, 13 deletions
diff --git a/src/libstd/rt/io/buffered.rs b/src/libstd/rt/io/buffered.rs
index 3e801f28991..a8cf8151499 100644
--- a/src/libstd/rt/io/buffered.rs
+++ b/src/libstd/rt/io/buffered.rs
@@ -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()
     }
 }
 
diff --git a/src/test/auxiliary/issue_9155.rs b/src/test/auxiliary/issue_9155.rs
new file mode 100644
index 00000000000..486eb8fd6f6
--- /dev/null
+++ b/src/test/auxiliary/issue_9155.rs
@@ -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)
+    }
+}
diff --git a/src/test/run-pass/issue_9155.rs b/src/test/run-pass/issue_9155.rs
new file mode 100644
index 00000000000..ba92a0c7b1f
--- /dev/null
+++ b/src/test/run-pass/issue_9155.rs
@@ -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);
+}