diff --git a/src/libcore/io.rs b/src/libcore/io.rs index e5a20909b7f..fab125c8d68 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -687,7 +687,7 @@ struct BytesWriter { mut pos: uint, } -impl @BytesWriter: Writer { +impl BytesWriter: Writer { fn write(v: &[const u8]) { do self.buf.swap |buf| { let mut buf <- buf; @@ -716,12 +716,20 @@ fn flush() -> int { 0 } fn get_type() -> WriterType { File } } -fn BytesWriter() -> @BytesWriter { - @BytesWriter { buf: DVec(), mut pos: 0u } +impl @BytesWriter : Writer { + fn write(v: &[const u8]) { (*self).write(v) } + fn seek(offset: int, whence: SeekStyle) { (*self).seek(offset, whence) } + fn tell() -> uint { (*self).tell() } + fn flush() -> int { (*self).flush() } + fn get_type() -> WriterType { (*self).get_type() } +} + +fn BytesWriter() -> BytesWriter { + BytesWriter { buf: DVec(), mut pos: 0u } } fn with_bytes_writer(f: fn(Writer)) -> ~[u8] { - let wr = BytesWriter(); + let wr = @BytesWriter(); f(wr as Writer); wr.buf.check_out(|buf| buf) } diff --git a/src/rustc/metadata/encoder.rs b/src/rustc/metadata/encoder.rs index 1b9fc64dd86..a45f2580364 100644 --- a/src/rustc/metadata/encoder.rs +++ b/src/rustc/metadata/encoder.rs @@ -1093,7 +1093,7 @@ fn encode_hash(ebml_w: ebml::Writer, hash: ~str) { 0, 0, 0, 1 ]; fn encode_metadata(parms: encode_parms, crate: @crate) -> ~[u8] { - let wr = io::BytesWriter(); + let wr = @io::BytesWriter(); let stats = {mut inline_bytes: 0, mut attr_bytes: 0,