I'm trying to create a recursive inner function that will print all elements in a linked list:
fn print_stack(&self) {
fn print_nodes(head: &Option<Box<Node<T>>>) {
match head {
Some(ref p) => {
println!("{:?}",p.data);
print_nodes(head.next);
},
}
};
print_nodes(&self.head);
}
The compiler generates the following error
can't use type parameters from outer function; try using a local type parameter instead.
Why is this an error?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With