Skip to content

Commit edb2118

Browse files
committed
doc: 'reader' and 'writer' are nicer to read than 'r' and 'w'
1 parent d7185dc commit edb2118

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/libstd/io/util.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,30 @@ use io::{self, Read, Write, ErrorKind, BufRead};
1616

1717
/// Copies the entire contents of a reader into a writer.
1818
///
19-
/// This function will continuously read data from `r` and then write it into
20-
/// `w` in a streaming fashion until `r` returns EOF.
19+
/// This function will continuously read data from `reader` and then
20+
/// write it into `writer` in a streaming fashion until `reader`
21+
/// returns EOF.
2122
///
22-
/// On success the total number of bytes that were copied from `r` to `w` is
23-
/// returned.
23+
/// On success, the total number of bytes that were copied from
24+
/// `reader` to `writer` is returned.
2425
///
2526
/// # Errors
2627
///
2728
/// This function will return an error immediately if any call to `read` or
2829
/// `write` returns an error. All instances of `ErrorKind::Interrupted` are
2930
/// handled by this function and the underlying operation is retried.
3031
#[stable(feature = "rust1", since = "1.0.0")]
31-
pub fn copy<R: Read, W: Write>(r: &mut R, w: &mut W) -> io::Result<u64> {
32+
pub fn copy<R: Read, W: Write>(reader: &mut R, writer: &mut W) -> io::Result<u64> {
3233
let mut buf = [0; super::DEFAULT_BUF_SIZE];
3334
let mut written = 0;
3435
loop {
35-
let len = match r.read(&mut buf) {
36+
let len = match reader.read(&mut buf) {
3637
Ok(0) => return Ok(written),
3738
Ok(len) => len,
3839
Err(ref e) if e.kind() == ErrorKind::Interrupted => continue,
3940
Err(e) => return Err(e),
4041
};
41-
try!(w.write_all(&buf[..len]));
42+
try!(writer.write_all(&buf[..len]));
4243
written += len as u64;
4344
}
4445
}

0 commit comments

Comments
 (0)