Open elftausend opened 11 months ago
This is certainly an interesting idea to do in debug mode. I think for FFI / serialization purposes it should be a best-effort optional thing though. So the location would be inside an Option
and the test would be self.loc.zip(other.loc).map(|a, b| a == b).unwrap_or(true)
.
This pull request refers to the following statement located in the docs:
However, there may be a way to detect such occurrences during runtime, though. It utilises the
core::panic::Location
and#[track_caller]
to match aSlotMap
with aDefaultKey
. This mechanic is used inRefCell
as well.I implemented a proof-of-concept for
SlotMap
only and would like to hear your opinion about this idea.