Want to raise this as a discussion issue rather than just writing the PR, but I think that remove_mapping should just take a MapEntry as argument. In particular, this will let us use the borrow checker to check lifetimes of mappings, since remove_mapping will drop the MapEntry, so we can guarantee that the user no longer has a reference to it after it's removed. (On a broader note, this is why I don't like the idea of "fighting the borrow-checker": this is a case where we can make the borrow-checker work for us to ensure correctness, not just to ensure memory safety.)
Want to raise this as a discussion issue rather than just writing the PR, but I think that
remove_mappingshould just take aMapEntryas argument. In particular, this will let us use the borrow checker to check lifetimes of mappings, sinceremove_mappingwill drop theMapEntry, so we can guarantee that the user no longer has a reference to it after it's removed. (On a broader note, this is why I don't like the idea of "fighting the borrow-checker": this is a case where we can make the borrow-checker work for us to ensure correctness, not just to ensure memory safety.)