mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Merge pull request #3706 from erickt/str-with-capacity
libcore: add a str::with_capacity to match the fn in vec
This commit is contained in:
commit
ebce09702f
@ -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…
Reference in New Issue
Block a user