Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions library/core/src/io/borrowed_buf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,14 @@ pub struct BorrowedCursor<'a, T> {
borrowed_buf: NonNull<BorrowedBuf<'a, T>>,
}

// SAFETY: A `BorrowedCursor<'a, T>` is a unique borrow of a `BorrowedBuf<'a, T>`, which is a
// `&'a mut [MaybeUninit<T>]` and two `Copy` fields. The `buf` raw pointer is used like
// `&mut [MaybeUninit<T>]` so `T: Send` -> `Send` and is: `T: Sync` -> `Sync`, and the
// `borrowed_buf` only touches two `Copy` fields, without depending of `T`.
unsafe impl<T: Send> Send for BorrowedCursor<'_, T> {}
// SAFETY: See the `Send` impl above.
unsafe impl<T: Sync> Sync for BorrowedCursor<'_, T> {}

impl<T> Debug for BorrowedCursor<'_, T> {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
let buf = BorrowedBufDebug {
Expand Down
Loading