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:
Daniel Micay
2014-11-11 16:01:29 -05:00
parent 9c96a79a74
commit 85c2c2e38c
24 changed files with 120 additions and 129 deletions

View File

@@ -1297,9 +1297,9 @@ impl<'a> Writer for &'a mut Writer+'a {
/// # fn process_input<R: Reader>(r: R) {}
/// # fn foo () {
/// use std::io::util::TeeReader;
/// use std::io::{stdin, MemWriter, ByRefWriter};
/// use std::io::{stdin, ByRefWriter};
///
/// let mut output = MemWriter::new();
/// let mut output = Vec::new();
///
/// {
/// // Don't give ownership of 'output' to the 'tee'. Instead we keep a
@@ -1308,7 +1308,7 @@ impl<'a> Writer for &'a mut Writer+'a {
/// process_input(tee);
/// }
///
/// println!("input processed: {}", output.unwrap());
/// println!("input processed: {}", output);
/// # }
/// ```
pub struct RefWriter<'a, W:'a> {