std: Standardize (input, output) param orderings

This functions swaps the order of arguments to a few functions that previously
took (output, input) parameters, but now take (input, output) parameters (in
that order).

The affected functions are:

* ptr::copy
* ptr::copy_nonoverlapping
* slice::bytes::copy_memory
* intrinsics::copy
* intrinsics::copy_nonoverlapping

Closes #22890
[breaking-change]
This commit is contained in:
Alex Crichton
2015-03-27 11:12:28 -07:00
parent 14192d6df5
commit acd48a2b3e
29 changed files with 147 additions and 107 deletions

View File

@@ -149,7 +149,7 @@ impl<'a> Read for &'a [u8] {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
let amt = cmp::min(buf.len(), self.len());
let (a, b) = self.split_at(amt);
slice::bytes::copy_memory(buf, a);
slice::bytes::copy_memory(a, buf);
*self = b;
Ok(amt)
}
@@ -170,7 +170,7 @@ impl<'a> Write for &'a mut [u8] {
fn write(&mut self, data: &[u8]) -> io::Result<usize> {
let amt = cmp::min(data.len(), self.len());
let (a, b) = mem::replace(self, &mut []).split_at_mut(amt);
slice::bytes::copy_memory(a, &data[..amt]);
slice::bytes::copy_memory(&data[..amt], a);
*self = b;
Ok(amt)
}