3 io::{self, Read, Write},
5 process::{Child, Command, Stdio},
8 use vector_math_build_helpers::make_context_types;
10 fn format_source(source: String) -> String {
11 let rustfmt_path = which::which("rustfmt").unwrap();
12 let mut command = Command::new(rustfmt_path)
13 .stdin(Stdio::piped())
14 .stdout(Stdio::piped())
17 let stdin = command.stdin.take().unwrap();
18 let reader_thread = thread::spawn(move || -> io::Result<(String, Child)> {
19 let mut output = String::new();
20 command.stdout.take().unwrap().read_to_string(&mut output)?;
23 { stdin }.write_all(source.as_bytes()).unwrap();
24 let (output, mut command) = reader_thread.join().unwrap().unwrap();
25 let exit_status = command.wait().unwrap();
26 assert!(exit_status.success());
32 Path::new(&env::var_os("OUT_DIR").unwrap()).join("context_trait.rs"),
33 format_source(make_context_types().to_string()),