Skip to content

Commit 13eb259

Browse files
committed
change FileDescriptor instance methods to use &mut self
1 parent ece709f commit 13eb259

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/libstd/rt/uv/file.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ impl FileDescriptor {
147147
}
148148

149149
// as per bnoordhuis in #libuv: offset >= 0 uses prwrite instead of write
150-
fn write_common(&self, loop_: Loop, buf: Buf, offset: i64, cb: Option<FsCallback>)
150+
fn write_common(&mut self, loop_: Loop, buf: Buf, offset: i64, cb: Option<FsCallback>)
151151
-> int {
152152
let complete_cb_ptr = match cb {
153153
Some(_) => compl_cb,
@@ -166,16 +166,16 @@ impl FileDescriptor {
166166
if is_sync { req.cleanup_and_delete(); }
167167
result
168168
}
169-
pub fn write(&self, loop_: Loop, buf: Buf, offset: i64, cb: FsCallback)
169+
pub fn write(&mut self, loop_: Loop, buf: Buf, offset: i64, cb: FsCallback)
170170
-> int {
171171
self.write_common(loop_, buf, offset, Some(cb))
172172
}
173-
pub fn write_sync(&self, loop_: Loop, buf: Buf, offset: i64)
173+
pub fn write_sync(&mut self, loop_: Loop, buf: Buf, offset: i64)
174174
-> int {
175175
self.write_common(loop_, buf, offset, None)
176176
}
177177

178-
fn read_common(&self, loop_: Loop, buf: Buf,
178+
fn read_common(&mut self, loop_: Loop, buf: Buf,
179179
offset: i64, cb: Option<FsCallback>)
180180
-> int {
181181
let complete_cb_ptr = match cb {
@@ -194,11 +194,11 @@ impl FileDescriptor {
194194
if is_sync { req.cleanup_and_delete(); }
195195
result
196196
}
197-
pub fn read(&self, loop_: Loop, buf: Buf, offset: i64, cb: FsCallback)
197+
pub fn read(&mut self, loop_: Loop, buf: Buf, offset: i64, cb: FsCallback)
198198
-> int {
199199
self.read_common(loop_, buf, offset, Some(cb))
200200
}
201-
pub fn read_sync(&self, loop_: Loop, buf: Buf, offset: i64)
201+
pub fn read_sync(&mut self, loop_: Loop, buf: Buf, offset: i64)
202202
-> int {
203203
self.read_common(loop_, buf, offset, None)
204204
}
@@ -294,7 +294,7 @@ mod test {
294294
|req, uverr| {
295295
let loop_ = req.get_loop();
296296
assert!(uverr.is_none());
297-
let fd = FileDescriptor::from_open_req(req);
297+
let mut fd = FileDescriptor::from_open_req(req);
298298
let raw_fd = fd.native_handle();
299299
let buf = unsafe { *write_buf_ptr };
300300
do fd.write(loop_, buf, -1) |_, uverr| {
@@ -306,7 +306,7 @@ mod test {
306306
|req, uverr| {
307307
assert!(uverr.is_none());
308308
let loop_ = req.get_loop();
309-
let fd = FileDescriptor::from_open_req(req);
309+
let mut fd = FileDescriptor::from_open_req(req);
310310
let raw_fd = fd.native_handle();
311311
let read_buf = unsafe { *read_buf_ptr };
312312
do fd.read(loop_, read_buf, 0) |req, uverr| {
@@ -360,7 +360,7 @@ mod test {
360360
create_flags as int, mode as int);
361361
assert!(status_to_maybe_uv_error_with_loop(
362362
loop_.native_handle(), result as i32).is_none());
363-
let fd = FileDescriptor(result as i32);
363+
let mut fd = FileDescriptor(result as i32);
364364
// write
365365
let result = fd.write_sync(loop_, write_buf, -1);
366366
assert!(status_to_maybe_uv_error_with_loop(
@@ -375,7 +375,7 @@ mod test {
375375
assert!(status_to_maybe_uv_error_with_loop(
376376
loop_.native_handle(), result as i32).is_none());
377377
let len = 1028;
378-
let fd = FileDescriptor(result as i32);
378+
let mut fd = FileDescriptor(result as i32);
379379
// read
380380
let read_mem: ~[u8] = vec::from_elem(len, 0u8);
381381
let buf = slice_to_uv_buf(read_mem);
@@ -413,7 +413,7 @@ mod test {
413413
}
414414
415415
fn naive_print(loop_: Loop, input: &str) {
416-
let stdout = FileDescriptor(STDOUT_FILENO);
416+
let mut stdout = FileDescriptor(STDOUT_FILENO);
417417
let write_val = input.as_bytes();
418418
let write_buf = slice_to_uv_buf(write_val);
419419
stdout.write_sync(loop_, write_buf, -1);

0 commit comments

Comments
 (0)