Add fixes for new lifetime bounds

This commit is contained in:
Dan Schatzberg 2014-10-02 14:06:31 -04:00
parent 0c63a4a4f5
commit 49e593c3d6
2 changed files with 8 additions and 11 deletions

View File

@ -46,12 +46,12 @@ struct AbsEntries<T> {
}
/// An iterator over a BTreeMap's entries.
pub struct Entries<'a, K, V> {
pub struct Entries<'a, K: 'a, V: 'a> {
inner: AbsEntries<Traversal<'a, K, V>>
}
/// A mutable iterator over a BTreeMap's entries.
pub struct MutEntries<'a, K, V> {
pub struct MutEntries<'a, K: 'a, V: 'a> {
inner: AbsEntries<MutTraversal<'a, K, V>>
}

View File

@ -849,9 +849,9 @@ impl<T> Vec<T> {
let cap = self.cap;
let begin = self.ptr as *const T;
let end = if mem::size_of::<T>() == 0 {
(ptr as uint + self.len()) as *const T;
(ptr as uint + self.len()) as *const T
} else {
ptr.offset(self.len() as int)
ptr.offset(self.len() as int) as *const T
};
mem::forget(self);
MoveItems { allocation: ptr, cap: cap, ptr: begin, end: end }
@ -1788,7 +1788,7 @@ impl<T> MoveItems<T> {
pub fn unwrap(mut self) -> Vec<T> {
unsafe {
for _x in self { }
let MoveItems { allocation, cap, iter: _iter } = self;
let MoveItems { allocation, cap, ptr: _ptr, end: _end } = self;
mem::forget(self);
Vec { ptr: allocation, cap: cap, len: 0 }
}
@ -2569,33 +2569,30 @@ mod tests {
fn test_move_items() {
let mut vec = vec!(1i, 2, 3);
let mut vec2 : Vec<int> = vec!();
for i in vec.move_iter() {
for i in vec.into_iter() {
vec2.push(i);
}
assert!(vec2 == vec!(1i, 2, 3));
assert!(vec.empty());
}
#[test]
fn test_move_items_reverse() {
let mut vec = vec!(1i, 2, 3);
let mut vec2 : Vec<int> = vec!();
for i in vec.move_iter().rev() {
for i in vec.into_iter().rev() {
vec2.push(i);
}
assert!(vec2 == vec!(3i, 2, 1));
assert!(vec.empty());
}
#[test]
fn test_move_items_zero_sized() {
let mut vec = vec!((), (), ());
let mut vec2 : Vec<()> = vec!();
for i in vec.move_iter() {
for i in vec.into_iter() {
vec2.push(i);
}
assert!(vec2 == vec!((), (), ()));
assert!(vec.empty());
}
#[bench]