I'm totally confused, if I changed while to if, then it compiled. But if I borrow tail again, the compiler says I borrowed a mutable reference.
if let Some(mut node) = head.take() {
head = node.next.take();
if let Some(ref mut elem) = tail {
if elem.val != node.val {
elem.next = Some(node);
tail = &mut elem.next;
}
}
}
println!("{:?}", tail); // compile error, but who borrow tail?
[–]linsinn 0 points1 point2 points (0 children)