[Pre-RFC] NonInternalMut auto trait (never mind)


#1

This post is removed by the author. The idea is incorrect. Thanks for your attention!


#2

Making code that used to compile not compile is a breaking change.


#3

It’s entirely possible to write a type that has interior mutability and upholds the invariants necessary for HashMap and BTreeMap to work.


#4

This also breaks all code that is parameterized over a type used as a key in a hashmap or hashset.


#5

Em, you are right. Thanks for all your reply. I would like to withdraw this post.

Thanks again!


#6

As an aside, please don’t do that! It’s pretty frustrating to come by and only see the remnants of a discussion. Nobodys judging you for starting a thread that did not turn into a revolution, so just leave it be, others might be interested nonetheless.


#7

Also, if you withdraw it then no one with the same idaya in the future can google to find the past discussion.


#8

Sorry for the inconvenience. My basic idea of this post is to introduce a auto trait NonInteriorMut to indicate whether a type has interior mutability or not. And add this trait as a constraint to the key type of associative containers (HashMap BTreeMap etc), to prevent keys being modified when they are in the container.