Because when I remove the .borrow_mut().insert_label(iri); part the code run perfectly. My guessing is that for some reason the RefMut created bY THIS specific borrow_mut() is not dropped automatically. But I don't understand why.
The string "already mutably borrowed" seems to come from the RefCell::borrow function when clone is called. Does putting the borrow_mut into a block help ?
let mut node = node_ref.borrow_mut();
node.insert_label(iri);
drop(node);
@tobi34 from my tests the error orriginate because of the .borrow_mut() doesn't seems to drop the RefMut created. While it should simply borrow the Rc<RefCell> as a RefMut and drop it at the end of the function. Nevertheless I tried the following:
This was going to be my advise. Never create a variable to hold a guard (like borrow_mut() creates) unless your actual goal is to hold onto the guard until the end of the block.
Thanks a lot, droping the graph solved the problem. I also add a more subtle bug releated when creating an edge between two nodes when the two nodes where the same.
This is solved.