Skip to content
Browse files

libcore: add a str::with_capacity to match the fn in vec

  • Loading branch information...
1 parent 22efa39 commit bdc1b7a8a71b0168a26e1f897246abc6c6ab1091 @erickt erickt committed Oct 9, 2012
Showing with 5 additions and 0 deletions.
  1. +5 −0 src/libcore/str.rs
View
5 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

0 comments on commit bdc1b7a

Please sign in to comment.
Something went wrong with that request. Please try again.