Convert vec::{reserve, reserve_at_least, capacity} to methods.

This commit is contained in:
Huon Wilson
2013-06-28 00:40:47 +10:00
parent ae2f185349
commit 32d655916f
7 changed files with 88 additions and 90 deletions

View File

@@ -2081,7 +2081,7 @@ impl OwnedStr for ~str {
pub fn reserve(&mut self, n: uint) {
unsafe {
let v: *mut ~[u8] = cast::transmute(self);
vec::reserve(&mut *v, n + 1);
(*v).reserve(n + 1);
}
}
@@ -2115,8 +2115,8 @@ impl OwnedStr for ~str {
* reallocating
*/
fn capacity(&self) -> uint {
let buf: &const ~[u8] = unsafe { cast::transmute(self) };
let vcap = vec::capacity(buf);
let buf: &~[u8] = unsafe { cast::transmute(self) };
let vcap = buf.capacity();
assert!(vcap > 0u);
vcap - 1u
}