Hi,

I don't know how to figure out calling by_ref() for a PipeStream:

use std::io::Process;
use std::io::BufferedReader;

fn main() {

  let mut child = match Process::new("/usr/bin/xzcat",
                                     ["test.log.xz".to_owned()]) {
    Ok(child) => child,
    Err(e) => fail!("failed to execute child: {}", e),
  };

  let inp = child.stdout.get_mut_ref();
  // ERROR occurs here
  let mut rdr = BufferedReader::new(inp.by_ref());

  for line in rdr.lines() {
    print!("{}", line.unwrap());
  }

  assert!(child.wait().success());
}


This is the error output:

test.rs:13:37: 13:49 error: multiple applicable methods in scope
test.rs:13   let mut rdr = BufferedReader::new(inp.by_ref());
                                               ^~~~~~~~~~~~
test.rs:13:37: 13:49 note: candidate #1 is `std::io::Writer::by_ref`
test.rs:13   let mut rdr = BufferedReader::new(inp.by_ref());
                                               ^~~~~~~~~~~~
test.rs:13:37: 13:49 note: candidate #2 is `std::io::Reader::by_ref`
test.rs:13   let mut rdr = BufferedReader::new(inp.by_ref());
                                               ^~~~~~~~~~~~
test.rs:13:17: 13:36 error: failed to find an implementation of trait std::io::Reader for std::io::RefWriter<,std::io::pipe::PipeStream>
test.rs:13   let mut rdr = BufferedReader::new(inp.by_ref());
                           ^~~~~~~~~~~~~~~~~~~


Any hints?

Actually what I want to accomplish is to iterate line by line over a
PipeStream.

Regards,

  Michael
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to