Skip to content

Commit 1f0757c

Browse files
committed
libstd: Allow io writer to write mutable arrays
1 parent af41564 commit 1f0757c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/libstd/io.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,15 +256,15 @@ type buf_writer =
256256
// FIXME: eventually u64
257257

258258
obj {
259-
fn write([u8]);
259+
fn write([const u8]);
260260
fn seek(int, seek_style);
261261
fn tell() -> uint;
262262
fn flush() -> int;
263263
fn fsync(level: fsync::level) -> int;
264264
};
265265

266266
obj FILE_writer(f: os::libc::FILE, res: option::t<@FILE_res>) {
267-
fn write(v: [u8]) unsafe {
267+
fn write(v: [const u8]) unsafe {
268268
let len = vec::len::<u8>(v);
269269
let vbuf = vec::unsafe::to_ptr::<u8>(v);
270270
let nout = os::libc::fwrite(vbuf, len, 1u, f);
@@ -283,7 +283,7 @@ obj FILE_writer(f: os::libc::FILE, res: option::t<@FILE_res>) {
283283
resource fd_res(fd: fd_t) { os::libc::close(fd); }
284284

285285
obj fd_buf_writer(fd: fd_t, res: option::t<@fd_res>) {
286-
fn write(v: [u8]) unsafe {
286+
fn write(v: [const u8]) unsafe {
287287
let len = vec::len::<u8>(v);
288288
let count = 0u;
289289
let vbuf;
@@ -351,7 +351,7 @@ type writer =
351351
fn write_char(char);
352352
fn write_int(int);
353353
fn write_uint(uint);
354-
fn write_bytes([u8]);
354+
fn write_bytes([const u8]);
355355
fn write_le_uint(uint, uint);
356356
fn write_le_int(int, uint);
357357
fn write_be_uint(uint, uint);
@@ -384,7 +384,7 @@ obj new_writer(out: buf_writer) {
384384
}
385385
fn write_int(n: int) { out.write(str::bytes(int::to_str(n, 10u))); }
386386
fn write_uint(n: uint) { out.write(str::bytes(uint::to_str(n, 10u))); }
387-
fn write_bytes(bytes: [u8]) { out.write(bytes); }
387+
fn write_bytes(bytes: [const u8]) { out.write(bytes); }
388388
fn write_le_uint(n: uint, size: uint) {
389389
out.write(uint_to_le_bytes(n, size));
390390
}
@@ -435,7 +435,7 @@ type str_writer =
435435
type mutable_byte_buf = @{mutable buf: [mutable u8], mutable pos: uint};
436436

437437
obj byte_buf_writer(buf: mutable_byte_buf) {
438-
fn write(v: [u8]) {
438+
fn write(v: [const u8]) {
439439
// Fast path.
440440

441441
if buf.pos == vec::len(buf.buf) {

0 commit comments

Comments
 (0)