diff options
Diffstat (limited to 'src/libstd/io.rs')
| -rw-r--r-- | src/libstd/io.rs | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/libstd/io.rs b/src/libstd/io.rs index 347fa988856..e074eba68ae 100644 --- a/src/libstd/io.rs +++ b/src/libstd/io.rs @@ -48,6 +48,7 @@ implement `Reader` and `Writer`, where appropriate. use result::Result; +use clone::Clone; use container::Container; use int; use libc; @@ -1697,7 +1698,7 @@ pub fn with_bytes_writer(f: &fn(@Writer)) -> ~[u8] { let wr = @BytesWriter::new(); f(wr as @Writer); let @BytesWriter { bytes, _ } = wr; - copy *bytes + (*bytes).clone() } pub fn with_str_writer(f: &fn(@Writer)) -> ~str { @@ -1750,7 +1751,6 @@ pub fn read_whole_file(file: &Path) -> Result<~[u8], ~str> { pub mod fsync { use io::{FILERes, FdRes, fd_t}; - use kinds::Copy; use libc; use ops::Drop; use option::{None, Option, Some}; @@ -1775,21 +1775,20 @@ pub mod fsync { arg: Arg<t>, } - impl <t: Copy> Res<t> { + impl <t> Res<t> { pub fn new(arg: Arg<t>) -> Res<t> { Res { arg: arg } } } #[unsafe_destructor] - impl<T:Copy> Drop for Res<T> { + impl<T> Drop for Res<T> { fn drop(&self) { match self.arg.opt_level { None => (), Some(level) => { // fail hard if not succesful - assert!(((self.arg.fsync_fn)(copy self.arg.val, level) - != -1)); + assert!(((self.arg.fsync_fn)(&self.arg.val, level) != -1)); } } } @@ -1798,7 +1797,7 @@ pub mod fsync { pub struct Arg<t> { val: t, opt_level: Option<Level>, - fsync_fn: @fn(f: t, Level) -> int, + fsync_fn: @fn(f: &t, Level) -> int, } // fsync file after executing blk @@ -1810,7 +1809,7 @@ pub mod fsync { val: file.f, opt_level: opt_level, fsync_fn: |file, l| { unsafe { - os::fsync_fd(libc::fileno(file), l) as int + os::fsync_fd(libc::fileno(*file), l) as int } } })); @@ -1821,7 +1820,7 @@ pub mod fsync { blk: &fn(v: Res<fd_t>)) { blk(Res::new(Arg { val: fd.fd, opt_level: opt_level, - fsync_fn: |fd, l| os::fsync_fd(fd, l) as int + fsync_fn: |fd, l| os::fsync_fd(*fd, l) as int })); } @@ -1833,7 +1832,7 @@ pub mod fsync { blk: &fn(v: Res<@FSyncable>)) { blk(Res::new(Arg { val: o, opt_level: opt_level, - fsync_fn: |o, l| o.fsync(l) + fsync_fn: |o, l| (*o).fsync(l) })); } } @@ -1854,7 +1853,7 @@ mod tests { debug!(tmpfile); let frood: ~str = ~"A hoopy frood who really knows where his towel is."; - debug!(copy frood); + debug!(frood.clone()); { let out: @io::Writer = result::get( @@ -1863,7 +1862,7 @@ mod tests { } let inp: @io::Reader = result::get(&io::file_reader(tmpfile)); let frood2: ~str = inp.read_c_str(); - debug!(copy frood2); + debug!(frood2.clone()); assert_eq!(frood, frood2); } |
