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.)
If we wanted to let users remove pieces of mappings, this wouldn't work, but per class we just want them to be able to remove a whole mapping at a time.
Want to raise this as a discussion issue rather than just writing the PR, but I think that
remove_mapping
should just take aMapEntry
as argument. In particular, this will let us use the borrow checker to check lifetimes of mappings, sinceremove_mapping
will 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.)