Interior mutability and safety of ownership transfer in Rust
Rust Internals [Unofficial]
March 6, 2026
ogg:
Another option would be to require:
K: Clone, V: Cloneand explicitly clone each KV-pair during migration. This should be sound, but it would also be inefficient in many cases.
Note that calling Clone::clone() requires providing it a reference of type &Self, so, if K and V are caller-chosen types, this is equivalent to handing out references to the caller (or to a caller-provided function, at least). I am not familiar enough with your use case to say whether this is an unsoundness, but it's something to keep in mind whenever you consider using a Clone bound with unsafe code.
Discussion in the ATmosphere