In case one would like to create StableBTreeMap on the fly, e.g.
fn get_memory_for_something(index: u8) -> Memory {
MEMORY_MANAGER.with(|m| m.borrow().get(MemoryId::new( index)))
}
pub fn init_stable_something(index: u8) -> Something {
StableBTreeMap::init(get_memory_for_something(index))
}
Is there a better pattern than holding references to the generated MemoryId in another StableVec or similar stable structure to ensure the memory of the canister can be upgraded without loosing references to the memory?