Merge pull request #41 from bzindovic/bzindovic-part13-clarity-fix
[rust-101.git] / solutions / src / list.rs
index c7ae6ad2565651a2628536cce710d2e3cdb1c2c4..1c794fc3f81aa1da1849ce1ae1b620fe63ac8620 100644 (file)
@@ -204,4 +204,20 @@ mod tests {
         }
         assert_eq!(count.count.get(), 20);
     }
         }
         assert_eq!(count.count.get(), 20);
     }
+
+    #[test]
+    fn test_iter_mut() {
+        let mut l = LinkedList::<i32>::new();
+        for i in 0..5 {
+            l.push_back(i);
+        }
+
+        assert_eq!(l.pop_front(), Some(0));
+        assert_eq!(l.pop_back(), Some(4));
+
+        for (n, i) in l.iter_mut().enumerate() {
+            *i-=1;
+            assert_eq!(n as i32, *i);
+        }
+    }
 }
 }