@@ -16,29 +16,30 @@ use io::{self, Read, Write, ErrorKind, BufRead};
16
16
17
17
/// Copies the entire contents of a reader into a writer.
18
18
///
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.
21
22
///
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.
24
25
///
25
26
/// # Errors
26
27
///
27
28
/// This function will return an error immediately if any call to `read` or
28
29
/// `write` returns an error. All instances of `ErrorKind::Interrupted` are
29
30
/// handled by this function and the underlying operation is retried.
30
31
#[ 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 > {
32
33
let mut buf = [ 0 ; super :: DEFAULT_BUF_SIZE ] ;
33
34
let mut written = 0 ;
34
35
loop {
35
- let len = match r . read ( & mut buf) {
36
+ let len = match reader . read ( & mut buf) {
36
37
Ok ( 0 ) => return Ok ( written) ,
37
38
Ok ( len) => len,
38
39
Err ( ref e) if e. kind ( ) == ErrorKind :: Interrupted => continue ,
39
40
Err ( e) => return Err ( e) ,
40
41
} ;
41
- try!( w . write_all ( & buf[ ..len] ) ) ;
42
+ try!( writer . write_all ( & buf[ ..len] ) ) ;
42
43
written += len as u64 ;
43
44
}
44
45
}
0 commit comments