about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/str.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/libcore/str.rs b/src/libcore/str.rs
index 447cb59acf8..18a8f3d3702 100644
--- a/src/libcore/str.rs
+++ b/src/libcore/str.rs
@@ -1473,6 +1473,11 @@ pub pure fn from_utf16(v: &[u16]) -> ~str {
     move buf
 }
 
+pub pure fn with_capacity(capacity: uint) -> ~str {
+    let mut buf = ~"";
+    unsafe { reserve(&mut buf, capacity); }
+    move buf
+}
 
 /**
  * As char_len but for a slice of a string