From b7908febca68700b4c14be5b55e4121e9f9ddb06 Mon Sep 17 00:00:00 2001 From: Gleb Kozyrev Date: Mon, 17 Nov 2014 02:07:23 +0200 Subject: [PATCH] Remove duplicate code by using util::copy() --- src/libstd/io/fs.rs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/libstd/io/fs.rs b/src/libstd/io/fs.rs index 3f39dda650a..f4e795721cf 100644 --- a/src/libstd/io/fs.rs +++ b/src/libstd/io/fs.rs @@ -381,16 +381,8 @@ pub fn copy(from: &Path, to: &Path) -> IoResult<()> { let mut reader = try!(File::open(from)); let mut writer = try!(File::create(to)); - let mut buf = [0, ..io::DEFAULT_BUF_SIZE]; - loop { - let amt = match reader.read(&mut buf) { - Ok(n) => n, - Err(ref e) if e.kind == io::EndOfFile => { break } - Err(e) => return update_err(Err(e), from, to) - }; - try!(writer.write(buf[..amt])); - } + try!(super::util::copy(&mut reader, &mut writer)); chmod(to, try!(update_err(from.stat(), from, to)).perm) }