From b33f0df152fd2242a1ea88d0961065caecd228ac Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Tue, 22 Mar 2011 16:38:47 -0700 Subject: stdlib: Make writers seekable; switch file writers to the C FILE interface to make this work --- src/lib/_str.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/lib/_str.rs') diff --git a/src/lib/_str.rs b/src/lib/_str.rs index e73fd115..87eef514 100644 --- a/src/lib/_str.rs +++ b/src/lib/_str.rs @@ -7,7 +7,7 @@ native "rust" mod rustrt { fn str_buf(str s) -> sbuf; fn str_byte_len(str s) -> uint; fn str_alloc(uint n_bytes) -> str; - fn str_from_vec(vec[u8] b) -> str; + fn str_from_vec(vec[mutable? u8] b) -> str; fn str_from_cstr(sbuf cstr) -> str; fn str_from_buf(sbuf buf, uint len) -> str; fn refcount[T](str s) -> uint; @@ -109,7 +109,16 @@ fn from_bytes(vec[u8] v) : is_utf8(v) -> str { } // FIXME temp thing -fn unsafe_from_bytes(vec[u8] v) -> str { +fn unsafe_from_bytes(vec[mutable? u8] v) -> str { + ret rustrt.str_from_vec(v); +} + +// FIXME even temp-er thing; rustc can use "unsafe_from_bytes" above +fn unsafe_from_mutable_bytes(vec[mutable u8] mv) -> str { + let vec[u8] v = vec(); + for (mutable u8 b in mv) { + v += vec(b); + } ret rustrt.str_from_vec(v); } -- cgit v1.2.3