Mutable vs immutable objects

Well, there are a few aspects to this. Mutable objects without reference-identity can cause bugs at odd times. For example, consider a Person bean with a value-based equals method: Map<Person, String> map = … Person p = new Person(); map.put(p, “Hey, there!”); p.setName(“Daniel”); map.get(p); // => null The Person instance gets “lost” in the map … Read more

Cannot obtain a mutable reference when iterating a recursive structure: cannot borrow as mutable more than once at a time

It is possible… but I wish I had a more elegant solution. The trick is NOT to borrow from anchor, and therefore to juggle between two accumulators: one holding the reference to the current node the other being assigned the reference to the next node This leads me to: impl Recursive { fn back(&mut self) … Read more