Skip to content

Commit

Permalink
call out explicitly that general read needs to be called with an init…
Browse files Browse the repository at this point in the history
…ialized buffer
  • Loading branch information
RalfJung committed Jun 24, 2019
1 parent 7e08576 commit 1c12b1b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/libstd/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,9 +506,18 @@ pub trait Read {
///
/// No guarantees are provided about the contents of `buf` when this
/// function is called, implementations cannot rely on any property of the
/// contents of `buf` being true. It is recommended that implementations
/// contents of `buf` being true. It is recommended that *implementations*
/// only write data to `buf` instead of reading its contents.
///
/// Correspondingly, however, *users* of this trait may not assume any guarantees
/// about how the implementation uses `buf`. The trait is safe to implement,
/// so it is perfectly possible that the implementation might inspect that data.
/// As a caller, it is your responsibility to make sure that `buf` is initialized
/// before calling `read`. Calling `read` with an uninitialized `buf` (of the kind one
/// obtains via [`MaybeUninit<T>`]) is not safe, and can lead to undefined behavior.
///
/// [`MaybeUninit<T>`]: ../mem/union.MaybeUninit.html
///
/// # Errors
///
/// If this function encounters any form of I/O or other error, an error
Expand Down

0 comments on commit 1c12b1b

Please sign in to comment.