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

This commit is contained in:
Erick Tryzelaar 2012-10-09 08:36:06 -07:00
parent 22efa39382
commit bdc1b7a8a7

View File

@ -1473,6 +1473,11 @@ fn is_alphanumeric(s: &str) -> bool {
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