From 4f0e84f6cbde3462da2afde72bbfa4bc79a7f968 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sat, 17 May 2025 11:08:06 -0700 Subject: [PATCH] local_working_copy: take owned Read in write_file() It doesn't make sense to use the `Read` instance after calling `write_file()`, so the caller shouldn't need to hold on to the instance. This slightly simplifies a later patch replacing `Read` by `AsyncRead`. --- lib/src/local_working_copy.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/src/local_working_copy.rs b/lib/src/local_working_copy.rs index 24ece4579..088cb4647 100644 --- a/lib/src/local_working_copy.rs +++ b/lib/src/local_working_copy.rs @@ -1612,7 +1612,7 @@ impl TreeState { fn write_file( &self, disk_path: &Path, - contents: &mut dyn Read, + mut contents: impl Read, executable: bool, ) -> Result { let mut file = OpenOptions::new() @@ -1623,7 +1623,7 @@ impl TreeState { message: format!("Failed to open file {} for writing", disk_path.display()), err: err.into(), })?; - let size = io::copy(contents, &mut file).map_err(|err| CheckoutError::Other { + let size = io::copy(&mut contents, &mut file).map_err(|err| CheckoutError::Other { message: format!("Failed to write file {}", disk_path.display()), err: err.into(), })?; @@ -1851,8 +1851,8 @@ impl TreeState { deleted_files.insert(path); continue; } - MaterializedTreeValue::File(mut file) => { - self.write_file(&disk_path, &mut file.reader, file.executable)? + MaterializedTreeValue::File(file) => { + self.write_file(&disk_path, file.reader, file.executable)? } MaterializedTreeValue::Symlink { id: _, target } => { if self.symlink_support {