Skip to content

Commit 6b48f94

Browse files
committed
fix slice of Result into slice of u8
1 parent aea3e58 commit 6b48f94

File tree

1 file changed

+8
-1
lines changed
  • src/tools/run-make-support/src

1 file changed

+8
-1
lines changed

src/tools/run-make-support/src/run.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ fn run_common(name: &str) -> (Command, Output) {
4040
(cmd, output)
4141
}
4242

43+
fn read_bytes<R: Read>(mut reader: R) -> Result<Vec<u8>, std::io::Error> {
44+
let mut buffer = Vec::new();
45+
reader.read_to_end(&mut buffer)?;
46+
Ok(buffer)
47+
}
48+
4349
/// Run a command taking in standard input from a file, and passing an argument
4450
/// referring to a different file.
4551
pub fn stdin_command<P>(command: &str, stdin: P, argument: P)
@@ -58,7 +64,8 @@ pub fn stdin_command<P>(command: &str, stdin: P, argument: P)
5864
.unwrap();
5965

6066
let mut child_stdin = child.stdin.take().unwrap();
61-
child_stdin.write_all(reader.bytes().collect::<Vec<_>>().as_slice()).unwrap();
67+
let byte_slice = read_bytes(reader).expect("failed to read bytes of standard input").as_slice();
68+
child_stdin.write_all(byte_slice).unwrap();
6269
child_stdin.flush().unwrap();
6370

6471
child.wait_with_output().unwrap();

0 commit comments

Comments
 (0)