Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
cli: Remove manual `std::io::copy` implementation (#34409)
tidely05065985e709
diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rsindex d6ddf79ea6c..287c62b753f 100644--- a/crates/cli/src/main.rs+++ b/crates/cli/src/main.rs@@ -315,19 +315,19 @@ fn main() -> Result<()> {});let stdin_pipe_handle: Option<JoinHandle<anyhow::Result<()>>> =- stdin_tmp_file.map(|tmp_file| {+ stdin_tmp_file.map(|mut tmp_file| {thread::spawn(move || {- let stdin = std::io::stdin().lock();- if io::IsTerminal::is_terminal(&stdin) {- return Ok(());+ let mut stdin = std::io::stdin().lock();+ if !io::IsTerminal::is_terminal(&stdin) {+ io::copy(&mut stdin, &mut tmp_file)?;}- return pipe_to_tmp(stdin, tmp_file);+ Ok(())})});- let anonymous_fd_pipe_handles: Vec<JoinHandle<anyhow::Result<()>>> = anonymous_fd_tmp_files+ let anonymous_fd_pipe_handles: Vec<_> = anonymous_fd_tmp_files.into_iter()- .map(|(file, tmp_file)| thread::spawn(move || pipe_to_tmp(file, tmp_file)))+ .map(|(mut file, mut tmp_file)| thread::spawn(move || io::copy(&mut file, &mut tmp_file))).collect();if args.foreground {@@ -349,22 +349,6 @@ fn main() -> Result<()> {Ok(())}-fn pipe_to_tmp(mut src: impl io::Read, mut dest: fs::File) -> Result<()> {- let mut buffer = [0; 8 * 1024];- loop {- let bytes_read = match src.read(&mut buffer) {- Err(err) if err.kind() == io::ErrorKind::Interrupted => continue,- res => res?,- };- if bytes_read == 0 {- break;- }- io::Write::write_all(&mut dest, &buffer[..bytes_read])?;- }- io::Write::flush(&mut dest)?;- Ok(())-}-fn anonymous_fd(path: &str) -> Option<fs::File> {#[cfg(target_os = "linux")]{