From 62b9dc0326383ad1944e2ceb841d0bc9da05c648 Mon Sep 17 00:00:00 2001 From: Joseph Crail Date: Sat, 30 May 2015 19:05:31 -0400 Subject: [PATCH] Refactor method to auto-convert into byte array. When creating tests, we could pass a String, &str, or [u8] to the standard input. Previously, all arguments had to be manually converted to a reference to a [u8]. This update makes it more ergonomic. --- test/common/util.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/common/util.rs b/test/common/util.rs index f13c8f6f6..2d940e6c3 100644 --- a/test/common/util.rs +++ b/test/common/util.rs @@ -30,7 +30,7 @@ pub fn run(cmd: &mut Command) -> CmdResult { } } -pub fn run_piped_stdin(cmd: &mut Command, input: &[u8])-> CmdResult { +pub fn run_piped_stdin>(cmd: &mut Command, input: T)-> CmdResult { let mut command = cmd .stdin(Stdio::piped()) .stdout(Stdio::piped()) @@ -41,7 +41,7 @@ pub fn run_piped_stdin(cmd: &mut Command, input: &[u8])-> CmdResult { command.stdin .take() .unwrap_or_else(|| panic!("Could not take child process stdin")) - .write_all(input) + .write_all(input.as_ref()) .unwrap_or_else(|e| panic!("{}", e)); let prog = command.wait_with_output().unwrap();