3 ms·
Is there any explanation of this? Specifically i would like to understand how a single mutable reference is required for correctness in a single thread scenario
by giovannibajo1 7y ago
Is there any explanation of this? Specifically i would like to understand how a single mutable reference is required for correctness in a single thread scenario.
I’ve googled everywhere but I can’t find a single source of information that completely explains this, possibly showing realistic source code and elaborating the way it could generate memory errors or be miscompiled in case of multiple mutable references.
- steveklabnik 7y agohttps://manishearth.github.io/blog/2015/05/17/the-problem-with-shared-mutability/ https://manishearth.github.io/blog/2015/05/17/the-problem-wi... is what I usually link folks to. The TL;DR is: iterator invalidation can happen even without threads.
- giovannibajo1 7y agoThanks, exactly what I was looking for!
- aratakareigen 7y agoFor example, if I could push to a Vec while holding a slice to it, that would obviously lead to horrible behavior if the Vec needed to reallocate. Another example is if someone tried to use a Vec x inside the closure passed to x.drain.