@@ -328,7 +328,7 @@ impl ByteBuf: Reader {
328
328
fn tell() -> uint { self.pos }
329
329
}
330
330
331
- pub fn with_bytes_reader<t>(bytes: &[u8], f: fn(Reader) -> t) -> t {
331
+ pub pure fn with_bytes_reader<t>(bytes: &[u8], f: fn(Reader) -> t) -> t {
332
332
f({buf: bytes, mut pos: 0u} as Reader)
333
333
}
334
334
@@ -730,21 +730,25 @@ impl @BytesWriter : Writer {
730
730
fn get_type() -> WriterType { (*self).get_type() }
731
731
}
732
732
733
- pub fn BytesWriter() -> BytesWriter {
733
+ pub pure fn BytesWriter() -> BytesWriter {
734
734
BytesWriter { buf: DVec(), mut pos: 0u }
735
735
}
736
736
737
- pub fn with_bytes_writer(f: fn(Writer)) -> ~[u8] {
737
+ pub pure fn with_bytes_writer(f: fn(Writer)) -> ~[u8] {
738
738
let wr = @BytesWriter();
739
739
f(wr as Writer);
740
- wr.buf.check_out(|buf| move buf)
740
+ // FIXME (#3758): This should not be needed.
741
+ unsafe { wr.buf.check_out(|buf| move buf) }
741
742
}
742
743
743
- pub fn with_str_writer(f: fn(Writer)) -> ~str {
744
+ pub pure fn with_str_writer(f: fn(Writer)) -> ~str {
744
745
let mut v = with_bytes_writer(f);
745
746
746
- // Make sure the vector has a trailing null and is proper utf8.
747
- v.push(0);
747
+ // FIXME (#3758): This should not be needed.
748
+ unsafe {
749
+ // Make sure the vector has a trailing null and is proper utf8.
750
+ v.push(0);
751
+ }
748
752
assert str::is_utf8(v);
749
753
750
754
unsafe { move ::cast::transmute(move v) }
0 commit comments