Hi guys,
I am learning CIS 198 2016 fall course and working on the homework 02. I finished part of it but saw compiling error "cannot assign to immutable field curr.right"
I did some search but failed to solve it yet. You could find my code at Rust Playground
curr is not a &mut Node here, it is a mutable variable which holds & Node. That is, you can make curr to point to another Node, but you can't change the Node itself. You want to bind node with ref mut. If you know C, this is the difference between a constant pointer (char * const), a pointer to constant (char const *) and a constant pointer to constant (char const * const).
Ah, sorry, I was too terse. What I meant was that when you have factored the loop out, you can call the function recursively, instead of reassigning curr.