Closed dtolnay closed 8 years ago
r? @huonw
(I've picked a reviewer for you, use r? to override)
r? @apasel422
Looks good. It might be beneficial to have one more test that ensures that the every value is dropped exactly once:
#[test]
fn test_into_iter_drop() {
struct Counter<'a>(&'a mut usize);
impl<'a> Drop for Counter<'a> {
fn drop(&mut self) {
*self.0 += 1;
}
}
let mut a = 0;
let mut b = 0;
let mut c = 0;
{
let mut map = LinkedHashMap::new();
map.insert("a", Counter(&mut a));
map.insert("b", Counter(&mut b));
map.insert("c", Counter(&mut c));
let mut iter = map.into_iter();
iter.next();
iter.next_back();
}
assert_eq!(a, 1);
assert_eq!(b, 1);
assert_eq!(c, 1);
}
Nice. I added it.
Fixes #4.