feat(main): enhance demonstration of linked list operations with count tracking

This commit is contained in:
mynameisdeleted
2026-07-09 18:07:08 -04:00
parent b93b7f204f
commit 7372730119

View File

@@ -41,14 +41,22 @@ impl<T> LinkedList<T> {
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() {