Skip to content

Commit

Permalink
Add fixes for new lifetime bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
dschatzberg committed Oct 2, 2014
1 parent 0c63a4a commit 49e593c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/libcollections/btree/map.rs
Expand Up @@ -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>>
}

Expand Down
15 changes: 6 additions & 9 deletions src/libcollections/vec.rs
Expand Up @@ -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 }
Expand Down Expand Up @@ -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 }
}
Expand Down Expand Up @@ -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]
Expand Down

4 comments on commit 49e593c

@bors
Copy link
Contributor

@bors bors commented on 49e593c Oct 2, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at dschatzberg@49e593c

@bors
Copy link
Contributor

@bors bors commented on 49e593c Oct 2, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging dschatzberg/rust/items-bounds = 49e593c3 into auto

@bors
Copy link
Contributor

@bors bors commented on 49e593c Oct 2, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dschatzberg/rust/items-bounds = 49e593c3 merged ok, testing candidate = 544f7cc8

@bors
Copy link
Contributor

@bors bors commented on 49e593c Oct 2, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.