Can anyone help me review my binary tree insertion?



I’m wrapping my head around rust, I’ve read too many lists, and tried to implement some data structure myself. Here is my attempt, does it look good?

And I got few questions:

  • the book doesn’t say anything about the scope of match, and during my attempt, I found the scope of match is counterintuitive, I can only use Some(_) instead of Some(mut cur) in match, because otherwise compiler would not allow assigning in None branch, why is that?
  • it seems rust borrow checker does not work well with loop: I can not eliminate the use of cur in loop, otherwise checker would confused and refuse to compile. This took me several hours to find out it’s not my fault but checker’s. Is there any way I can eliminate cur?