io::Read trait: make it more clear when we are adressing implementations vs callers

This commit is contained in:
Ralf Jung 2024-03-10 09:39:45 +01:00
parent 5bc7b9ac8a
commit 93049bece0

View File

@ -692,10 +692,9 @@ pub trait Read {
/// Callers have to ensure that no unchecked out-of-bounds accesses are possible even if /// Callers have to ensure that no unchecked out-of-bounds accesses are possible even if
/// `n > buf.len()`. /// `n > buf.len()`.
/// ///
/// No guarantees are provided about the contents of `buf` when this /// *Implementations* of this method can make no assumptions about the contents of `buf` when
/// function is called, so implementations cannot rely on any property of the /// this function is called. It is recommended that implementations only write data to `buf`
/// contents of `buf` being true. It is recommended that *implementations* /// instead of reading its contents.
/// only write data to `buf` instead of reading its contents.
/// ///
/// Correspondingly, however, *callers* of this method in unsafe code must not assume /// Correspondingly, however, *callers* of this method in unsafe code must not assume
/// any guarantees about how the implementation uses `buf`. The trait is safe to implement, /// any guarantees about how the implementation uses `buf`. The trait is safe to implement,
@ -901,12 +900,10 @@ pub trait Read {
/// This function reads as many bytes as necessary to completely fill the /// This function reads as many bytes as necessary to completely fill the
/// specified buffer `buf`. /// specified buffer `buf`.
/// ///
/// No guarantees are provided about the contents of `buf` when this /// *Implementations* of this method can make no assumptions about the contents of `buf` when
/// function is called, so implementations cannot rely on any property of the /// this function is called. It is recommended that implementations only write data to `buf`
/// contents of `buf` being true. It is recommended that implementations /// instead of reading its contents. The documentation on [`read`] has a more detailed
/// only write data to `buf` instead of reading its contents. The /// explanation of this subject.
/// documentation on [`read`] has a more detailed explanation on this
/// subject.
/// ///
/// # Errors /// # Errors
/// ///