@@ -173,6 +173,30 @@ discard the stream anyways.
173
173
Users who need finer control should use the ` read ` method directly, or
174
174
when available use the ` Seek ` trait.
175
175
176
+ # About the buffer contents
177
+
178
+ This RFC proposes that the contents of the output buffer be undefined on
179
+ an error return. It might be untouched, partially overwritten, or
180
+ completely overwritten (even if less bytes could be read; for instance,
181
+ this method might in theory use it as a scratch space).
182
+
183
+ Two possible alternatives could be considered: do not touch it on
184
+ failure, or overwrite it with valid data as much as possible.
185
+
186
+ Never touching the output buffer on failure would make it much more
187
+ expensive for the default implementation (which calls ` read ` in a loop),
188
+ since it would have to read into a temporary buffer and copy to the
189
+ output buffer on success. Any implementation which cannot do an early
190
+ return for all failure cases would have similar extra costs.
191
+
192
+ Overwriting as much as possible with valid data makes some sense; it
193
+ happens without any extra cost in the default implementation. However,
194
+ for optimized implementations this extra work is useless; since the
195
+ caller can't know how much is valid data and how much is garbage, it
196
+ can't make use of the valid data.
197
+
198
+ Users who need finer control should use the ` read ` method directly.
199
+
176
200
# Naming
177
201
178
202
It's unfortunate that ` write_all ` used ` WriteZero ` for its ` ErrorKind ` ;
0 commit comments