Skip to content

Commit 04e2a5a

Browse files
authored
Buffer documentation clarifications (#1412)
* Fix doc comment on `Buffer::assume_init`: `len` is in elements, not bytes * Clarify documentation of `Buffer::parts_mut`: length is elements, not bytes
1 parent 4d5e6bf commit 04e2a5a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/buffer.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,8 @@ mod private {
293293

294294
/// Return a pointer and length for this buffer.
295295
///
296+
/// The length is the number of elements of type `T`, not a number of bytes.
297+
///
296298
/// It's tempting to have this return `&mut [MaybeUninit<T>]` instead,
297299
/// however that would require this function to be `unsafe`, because
298300
/// callers could use the `&mut [MaybeUninit<T>]` slice to set elements
@@ -304,7 +306,7 @@ mod private {
304306
///
305307
/// # Safety
306308
///
307-
/// At least `len` bytes of the buffer must now be initialized.
309+
/// At least `len` elements of the buffer must now be initialized.
308310
#[must_use]
309311
unsafe fn assume_init(self, len: usize) -> Self::Output;
310312
}

0 commit comments

Comments
 (0)