I VERY STRONGLY believe that there should be no way for safe rust code to be able to read from uninitialized memory. I would expect that Rust makes a best effort to protect me from doing this.
Accidentally reading from uninitialized memory is very easy and have the potential of having very serious implications (see heart bleed, but it is probably one of main vulnerability vectors). If Rust decides that it is ok to leak uninitialized memory into safe Rust code, I would consider that a serious hit against the advantages that Rust provides.
`
First of all, it’s not an and situation, it is an or situation. Either Rust provides a buffer abstraction that has essentially 0 performance penalty or it zeroes out memory, which has a small penalty. Also, we are specifically discussing functions like Read::read_to_end() which already are not good functions to be used in a performance sensitive situation. In a performance critical situation, one would allocate a buffer once (zero it out) and reuse it, making the point of zeroing out of memory having overhead moot . (Yes, you may say that a bug would expose contents previously written to this buffer, and this is true, but it WILL not expose memory that was never written to the buffer).
Also, I would not consider a buffer abstraction “API overhead” It makes working with bytes easier and is a pretty established abstraction.
Now, the exact same argument could be made against the borrow checker. Which means that once one requires cycles, EITHER a performance hit is needed (Arc / Rc / using a vec and passing around indexes) OR unsafe code is needed. This is what we buy in to when we are using Rust.