about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorDaniel Micay <danielmicay@gmail.com>2014-11-11 16:01:29 -0500
committerDaniel Micay <danielmicay@gmail.com>2014-11-18 01:09:46 -0500
commit85c2c2e38ce7c606fac1e9c8fa9d2ab71b35c8c8 (patch)
tree578802f9e774e104b1a271b92946208e0e0a0675 /src/libsyntax
parent9c96a79a74f10bed18b031ce0ac4126c56d6cfb3 (diff)
downloadrust-85c2c2e38ce7c606fac1e9c8fa9d2ab71b35c8c8.tar.gz
rust-85c2c2e38ce7c606fac1e9c8fa9d2ab71b35c8c8.zip
implement Writer for Vec<u8>
The trait has an obvious, sensible implementation directly on vectors so
the MemWriter wrapper is unnecessary. This will halt the trend towards
providing all of the vector methods on MemWriter along with eliminating
the noise caused by conversions between the two types. It also provides
the useful default Writer methods on Vec<u8>.

After the type is removed and code has been migrated, it would make
sense to add a new implementation of MemWriter with seeking support. The
simple use cases can be covered with vectors alone, and ones with the
need for seeks can use a new MemWriter implementation.
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/print/pprust.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index 81f3d977e13..0543b80f208 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -33,7 +33,7 @@ use print::pp;
 use ptr::P;
 
 use std::ascii;
-use std::io::{IoResult, MemWriter};
+use std::io::IoResult;
 use std::io;
 use std::mem;
 
@@ -169,17 +169,17 @@ impl<'a> State<'a> {
 
 pub fn to_string(f: |&mut State| -> IoResult<()>) -> String {
     use std::raw::TraitObject;
-    let mut s = rust_printer(box MemWriter::new());
+    let mut s = rust_printer(box Vec::new());
     f(&mut s).unwrap();
     eof(&mut s.s).unwrap();
     let wr = unsafe {
         // FIXME(pcwalton): A nasty function to extract the string from an `io::Writer`
-        // that we "know" to be a `MemWriter` that works around the lack of checked
+        // that we "know" to be a `Vec<u8>` that works around the lack of checked
         // downcasts.
         let obj: &TraitObject = mem::transmute(&s.s.out);
-        mem::transmute::<*mut (), &MemWriter>(obj.data)
+        mem::transmute::<*mut (), &Vec<u8>>(obj.data)
     };
-    String::from_utf8(wr.get_ref().to_vec()).unwrap()
+    String::from_utf8(wr.clone()).unwrap()
 }
 
 pub fn binop_to_string(op: BinOpToken) -> &'static str {