Take owned Read and Write (#12909)

# Description
As @YizhePKU pointed out, the [Rust API
guidelines](https://rust-lang.github.io/api-guidelines/interoperability.html#generic-readerwriter-functions-take-r-read-and-w-write-by-value-c-rw-value)
recommend that generic functions take readers and writers by value and
not by reference. This PR changes `copy_with_interupt` and few other
places to take owned `Read` and `Write` instead of mutable references.
This commit is contained in:
Ian Manske
2024-05-20 13:10:36 +00:00
committed by GitHub
parent c61075e20e
commit c98960d053
3 changed files with 36 additions and 46 deletions

View File

@@ -508,7 +508,7 @@ fn get_files(
}
fn stream_to_file(
mut source: impl Read,
source: impl Read,
known_size: Option<u64>,
ctrlc: Option<Arc<AtomicBool>>,
mut file: File,
@@ -555,7 +555,7 @@ fn stream_to_file(
Ok(())
}
} else {
copy_with_interrupt(&mut source, &mut file, span, ctrlc.as_deref())?;
copy_with_interrupt(source, file, span, ctrlc.as_deref())?;
Ok(())
}
}