libcore: add a str::with_capacity to match the fn in vec
This commit is contained in:
parent
22efa39382
commit
bdc1b7a8a7
@ -1473,6 +1473,11 @@ fn is_alphanumeric(s: &str) -> bool {
|
|||||||
move buf
|
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
|
* As char_len but for a slice of a string
|
||||||
|
Loading…
Reference in New Issue
Block a user