Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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



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

DerefMut to [T] not Vec<T>.




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: