`RefMut::map_split_ref` for (Ref, RefMut)?

Hi,
are there plans for a function like RefMut::map_split_ref, that returns (Ref, RefMut) or is there another way without going the unsafe route?

How would you get a RefMut from a immutable Ref?

Whoops, i mean something like RefMut::map_split_ref where you can make a Ref from a RefMut.

A RefCell keeps count of how many Ref or RefMut you have around, and that count is shared across any manner of splitting. So there's no way to to have a Ref and a RefMut tied to the same RefCell active at the same time with the current implementation.

1 Like

What do you need this for? Chances are there is a solution with an existing API.

I am trying to implement a database, where the query fetches different types of data that does not overlap. Something like this (simplified):

struct Database { data: HashMap<TypeId, TypeErasedCollection>, }

Now when I want to make a Query: Query<(&A, &mut B)>, I need to access this internally both shared and mutable. Since my database is for other reasons in a Rc<RefCell<Database>> anyway, I thought this would be a neat solution.