diff --git a/src/libcore/str.rs b/src/libcore/str.rs index 447cb59acf80..18a8f3d37024 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