Hacker News new | ask | show | jobs
by shim__ 64 days ago
DerefMut would allow you to call `clear()` on `v` violating the invariant

I'd be great is there were a way to shadow methods but even then guarantees would be poor since Vec might add a new method in the future which isn't covered by invariant checks

1 comments

clear() is a method of std::Vec not std::slice.

DerefMut to [T] not Vec<T>.