libsyntax: Fix errors arising from the automated ~[T]
conversion
This commit is contained in:
parent
58fd6ab90d
commit
198cc3d850
54 changed files with 577 additions and 306 deletions
|
@ -16,6 +16,7 @@ use clone::Clone;
|
|||
use cmp::{Eq, Ordering, TotalEq, TotalOrd};
|
||||
use container::Container;
|
||||
use default::Default;
|
||||
use fmt;
|
||||
use iter::{DoubleEndedIterator, FromIterator, Iterator};
|
||||
use libc::{free, c_void};
|
||||
use mem::{size_of, move_val_init};
|
||||
|
@ -82,6 +83,26 @@ impl<T: Clone> Vec<T> {
|
|||
self.push((*element).clone())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub fn grow(&mut self, n: uint, initval: &T) {
|
||||
let new_len = self.len() + n;
|
||||
self.reserve(new_len);
|
||||
let mut i: uint = 0u;
|
||||
|
||||
while i < n {
|
||||
self.push((*initval).clone());
|
||||
i += 1u;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn grow_set(&mut self, index: uint, initval: &T, val: T) {
|
||||
let l = self.len();
|
||||
if index >= l {
|
||||
self.grow(index - l + 1u, initval);
|
||||
}
|
||||
*self.get_mut(index) = val;
|
||||
}
|
||||
}
|
||||
|
||||
impl<T:Clone> Clone for Vec<T> {
|
||||
|
@ -388,6 +409,12 @@ impl<T> Default for Vec<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T:fmt::Show> fmt::Show for Vec<T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
self.as_slice().fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct MoveItems<T> {
|
||||
priv allocation: *mut c_void, // the block of memory allocated for the vector
|
||||
priv iter: Items<'static, T>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue