This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +12
-0
lines changed Expand file tree Collapse file tree 4 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -178,6 +178,9 @@ impl AsFd for BorrowedFd<'_> {
178178impl AsFd for OwnedFd {
179179 #[ inline]
180180 fn as_fd ( & self ) -> BorrowedFd < ' _ > {
181+ // Safety: `OwnedFd` and `BorrowedFd` have the same validity
182+ // invariants, and the `BorrowdFd` is bounded by the lifetime
183+ // of `&self`.
181184 unsafe { BorrowedFd :: borrow_raw_fd ( self . as_raw_fd ( ) ) }
182185 }
183186}
Original file line number Diff line number Diff line change @@ -177,6 +177,9 @@ impl AsFd for BorrowedFd<'_> {
177177impl AsFd for OwnedFd {
178178 #[ inline]
179179 fn as_fd ( & self ) -> BorrowedFd < ' _ > {
180+ // Safety: `OwnedFd` and `BorrowedFd` have the same validity
181+ // invariants, and the `BorrowdFd` is bounded by the lifetime
182+ // of `&self`.
180183 unsafe { BorrowedFd :: borrow_raw_fd ( self . as_raw_fd ( ) ) }
181184 }
182185}
Original file line number Diff line number Diff line change @@ -282,6 +282,9 @@ impl AsHandle for BorrowedHandle<'_> {
282282impl AsHandle for OwnedHandle {
283283 #[ inline]
284284 fn as_handle ( & self ) -> BorrowedHandle < ' _ > {
285+ // Safety: `OwnedHandle` and `BorrowedHandle` have the same validity
286+ // invariants, and the `BorrowdHandle` is bounded by the lifetime
287+ // of `&self`.
285288 unsafe { BorrowedHandle :: borrow_raw_handle ( self . as_raw_handle ( ) ) }
286289 }
287290}
Original file line number Diff line number Diff line change @@ -145,6 +145,9 @@ impl AsSocket for BorrowedSocket<'_> {
145145impl AsSocket for OwnedSocket {
146146 #[ inline]
147147 fn as_socket ( & self ) -> BorrowedSocket < ' _ > {
148+ // Safety: `OwnedSocket` and `BorrowedSocket` have the same validity
149+ // invariants, and the `BorrowdSocket` is bounded by the lifetime
150+ // of `&self`.
148151 unsafe { BorrowedSocket :: borrow_raw_socket ( self . as_raw_socket ( ) ) }
149152 }
150153}
You can’t perform that action at this time.
0 commit comments