Skip to content

Commit ebce097

Browse files
committed
Merge pull request #3706 from erickt/str-with-capacity
libcore: add a str::with_capacity to match the fn in vec
2 parents 7f12cc4 + bdc1b7a commit ebce097

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/libcore/str.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1473,6 +1473,11 @@ pub pure fn from_utf16(v: &[u16]) -> ~str {
14731473
move buf
14741474
}
14751475

1476+
pub pure fn with_capacity(capacity: uint) -> ~str {
1477+
let mut buf = ~"";
1478+
unsafe { reserve(&mut buf, capacity); }
1479+
move buf
1480+
}
14761481

14771482
/**
14781483
* As char_len but for a slice of a string

0 commit comments

Comments
 (0)