X-Git-Url: https://git.ralfj.de/rust-101.git/blobdiff_plain/383f5bdfee5830c66cd273f5b4ee9be47d093b31..6b1c55ec8e185fa09b395526deced8bcde7b71c6:/solutions/src/list.rs diff --git a/solutions/src/list.rs b/solutions/src/list.rs index c7ae6ad..1c794fc 100644 --- a/solutions/src/list.rs +++ b/solutions/src/list.rs @@ -204,4 +204,20 @@ mod tests { } assert_eq!(count.count.get(), 20); } + + #[test] + fn test_iter_mut() { + let mut l = LinkedList::::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); + } + } }