Input::read() is a safe method of a safe trait, it doesn't guarantee an invariant of not reading its argument. So it is possible to have a perfectly safe implementation of Input that reads some bytes before writing to them, but since they are uninitialized (you just blindly called Vec::set_len()), it is an instant undefined behavior!
The right thing to do is to have a separate unsafe method that takes a pointer or add a method that takes something like &mut [MaybeUninit<T>] instead.
Originally posted by @nazar-pc in #605 (comment)
Input::read()is a safe method of a safe trait, it doesn't guarantee an invariant of not reading its argument. So it is possible to have a perfectly safe implementation ofInputthat reads some bytes before writing to them, but since they are uninitialized (you just blindly calledVec::set_len()), it is an instant undefined behavior!The right thing to do is to have a separate unsafe method that takes a pointer or add a method that takes something like
&mut [MaybeUninit<T>]instead.Originally posted by @nazar-pc in #605 (comment)