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.
This commit is contained in:
parent
9c96a79a74
commit
85c2c2e38c
24 changed files with 120 additions and 129 deletions
|
|
@ -122,7 +122,6 @@ use util::nodemap::NodeMap;
|
|||
use std::fmt;
|
||||
use std::io;
|
||||
use std::rc::Rc;
|
||||
use std::str;
|
||||
use std::uint;
|
||||
use syntax::ast;
|
||||
use syntax::ast::*;
|
||||
|
|
@ -742,7 +741,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||
|
||||
#[allow(unused_must_use)]
|
||||
fn ln_str(&self, ln: LiveNode) -> String {
|
||||
let mut wr = io::MemWriter::new();
|
||||
let mut wr = Vec::new();
|
||||
{
|
||||
let wr = &mut wr as &mut io::Writer;
|
||||
write!(wr, "[ln({}) of kind {} reads", ln.get(), self.ir.lnk(ln));
|
||||
|
|
@ -751,7 +750,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||
self.write_vars(wr, ln, |idx| self.users[idx].writer);
|
||||
write!(wr, " precedes {}]", self.successors[ln.get()].to_string());
|
||||
}
|
||||
str::from_utf8(wr.unwrap().as_slice()).unwrap().to_string()
|
||||
String::from_utf8(wr).unwrap()
|
||||
}
|
||||
|
||||
fn init_empty(&mut self, ln: LiveNode, succ_ln: LiveNode) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue