Spent a looong time trying to understand recursive data structures/patterns in Rust. The bots and forums didn't even help much on this one... they too quickly turn to helper libraries.
For these structures (basically a linked list):
type List<T> = Option<Box<Node<T>>>;
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Node<T> {
pub val: T,
pub next: List<T>,
}
I finally landed on this succinct way to traverse:
// where head is a List<i32>
let mut current = head.as_ref();
while current.is_some() {
if let Some(x) = current { println!("value is {}", x.val); }
current = current.and_then(|x| x.next.as_ref());
}