about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorErick Tryzelaar <erick.tryzelaar@gmail.com>2012-10-18 09:04:47 -0700
committerErick Tryzelaar <erick.tryzelaar@gmail.com>2012-10-18 09:04:47 -0700
commitb18a15171bfbcde81c44967a865214389d6fd7ad (patch)
tree12c6131f3076d1848a6a1edcd3627fce1fe617d1 /src/libcore
parent4e03ffdb6547d9541de84b61d7798b497235472b (diff)
Make with_bytes_reader/with_bytes_writer pure
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/dvec.rs2
-rw-r--r--src/libcore/io.rs18
2 files changed, 12 insertions, 8 deletions
diff --git a/src/libcore/dvec.rs b/src/libcore/dvec.rs
index 1540eb30fe5..1b6a7522864 100644
--- a/src/libcore/dvec.rs
+++ b/src/libcore/dvec.rs
@@ -56,7 +56,7 @@ pub enum DVec<A> {
 }
 
 /// Creates a new, empty dvec
-pub fn DVec<A>() -> DVec<A> {
+pub pure fn DVec<A>() -> DVec<A> {
     DVec_({mut data: ~[]})
 }
 
diff --git a/src/libcore/io.rs b/src/libcore/io.rs
index fd0fcbbe1c1..41fc1bb1a69 100644
--- a/src/libcore/io.rs
+++ b/src/libcore/io.rs
@@ -328,7 +328,7 @@ impl ByteBuf: Reader {
     fn tell() -> uint { self.pos }
 }
 
-pub fn with_bytes_reader<t>(bytes: &[u8], f: fn(Reader) -> t) -> t {
+pub pure fn with_bytes_reader<t>(bytes: &[u8], f: fn(Reader) -> t) -> t {
     f({buf: bytes, mut pos: 0u} as Reader)
 }
 
@@ -730,21 +730,25 @@ impl @BytesWriter : Writer {
     fn get_type() -> WriterType { (*self).get_type() }
 }
 
-pub fn BytesWriter() -> BytesWriter {
+pub pure fn BytesWriter() -> BytesWriter {
     BytesWriter { buf: DVec(), mut pos: 0u }
 }
 
-pub fn with_bytes_writer(f: fn(Writer)) -> ~[u8] {
+pub pure fn with_bytes_writer(f: fn(Writer)) -> ~[u8] {
     let wr = @BytesWriter();
     f(wr as Writer);
-    wr.buf.check_out(|buf| move buf)
+    // FIXME (#3758): This should not be needed.
+    unsafe { wr.buf.check_out(|buf| move buf) }
 }
 
-pub fn with_str_writer(f: fn(Writer)) -> ~str {
+pub pure fn with_str_writer(f: fn(Writer)) -> ~str {
     let mut v = with_bytes_writer(f);
 
-    // Make sure the vector has a trailing null and is proper utf8.
-    v.push(0);
+    // FIXME (#3758): This should not be needed.
+    unsafe {
+        // Make sure the vector has a trailing null and is proper utf8.
+        v.push(0);
+    }
     assert str::is_utf8(v);
 
     unsafe { move ::cast::transmute(move v) }