Struct std::old_io::RefWriterUnstable
[-] [+]
[src]
pub struct RefWriter<'a, W: 'a> { // some fields omitted }
A RefWriter
is a struct implementing Writer
which contains a reference
to another writer. This is often useful when composing streams.
Example
fn main() { use std::old_io::util::TeeReader; use std::old_io::{stdin, ByRefWriter}; fn process_input<R: Reader>(r: R) {} let mut output = Vec::new(); { // Don't give ownership of 'output' to the 'tee'. Instead we keep a // handle to it in the outer scope let mut tee = TeeReader::new(stdin(), output.by_ref()); process_input(tee); } println!("input processed: {:?}", output); }use std::old_io::util::TeeReader; use std::old_io::{stdin, ByRefWriter}; fn process_input<R: Reader>(r: R) {} let mut output = Vec::new(); { // Don't give ownership of 'output' to the 'tee'. Instead we keep a // handle to it in the outer scope let mut tee = TeeReader::new(stdin(), output.by_ref()); process_input(tee); } println!("input processed: {:?}", output);