&gt;<p><pre><code>    pub fn evil(&amp;mut self) {
        self.len += 2;
    }
</code></pre>
Does it makes sense to think if it takes a mutable instance of the &quot;unsafe&quot; structure, then whatever it does to it could be &quot;usafe&quot;.<p>So it seems to fix it by hand, one could wrap all the calls which touch instances of this Vec with safe validation code -- basically guard code that runs at runtime to prevent corruptions from spreading. Can it be easily done during compile time?