diff --git a/src/main.rs b/src/main.rs index 751ef86..e7cefcc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -41,14 +41,22 @@ impl LinkedList { fn main() { let mut list = LinkedList::new(); + let mut count = 0; + let message1 = "hello world"; // Demonstrate pushing items list.push_front(10); + count += 1; list.push_front(20); + count += 1; list.push_front(30); + count += 1; - // Demonstrate peaking at the top item - println!("Top element: {:?}", list.peek_front()); // Output: Some(30) + // Demonstrate peeking at the top item + if let Some(top) = list.peek_front() { + println!("Top element: {}\ncount: {}", top, count); // Output: 30 + } + println!("{}", message1); // Demonstrate popping items while let Some(value) = list.pop_front() {