libcore: add a str::with_capacity to match the fn in vec
This commit is contained in:
parent
22efa39382
commit
bdc1b7a8a7
1 changed files with 5 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue