Add Safety comments to the As*
for Owned*
implementations.
This commit is contained in:
parent
6486f89cbc
commit
6d7211738d
@ -178,6 +178,9 @@ fn as_fd(&self) -> BorrowedFd<'_> {
|
||||
impl AsFd for OwnedFd {
|
||||
#[inline]
|
||||
fn as_fd(&self) -> BorrowedFd<'_> {
|
||||
// Safety: `OwnedFd` and `BorrowedFd` have the same validity
|
||||
// invariants, and the `BorrowdFd` is bounded by the lifetime
|
||||
// of `&self`.
|
||||
unsafe { BorrowedFd::borrow_raw_fd(self.as_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
@ -177,6 +177,9 @@ fn as_fd(&self) -> BorrowedFd<'_> {
|
||||
impl AsFd for OwnedFd {
|
||||
#[inline]
|
||||
fn as_fd(&self) -> BorrowedFd<'_> {
|
||||
// Safety: `OwnedFd` and `BorrowedFd` have the same validity
|
||||
// invariants, and the `BorrowdFd` is bounded by the lifetime
|
||||
// of `&self`.
|
||||
unsafe { BorrowedFd::borrow_raw_fd(self.as_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
@ -282,6 +282,9 @@ fn as_handle(&self) -> BorrowedHandle<'_> {
|
||||
impl AsHandle for OwnedHandle {
|
||||
#[inline]
|
||||
fn as_handle(&self) -> BorrowedHandle<'_> {
|
||||
// Safety: `OwnedHandle` and `BorrowedHandle` have the same validity
|
||||
// invariants, and the `BorrowdHandle` is bounded by the lifetime
|
||||
// of `&self`.
|
||||
unsafe { BorrowedHandle::borrow_raw_handle(self.as_raw_handle()) }
|
||||
}
|
||||
}
|
||||
|
@ -145,6 +145,9 @@ fn as_socket(&self) -> BorrowedSocket<'_> {
|
||||
impl AsSocket for OwnedSocket {
|
||||
#[inline]
|
||||
fn as_socket(&self) -> BorrowedSocket<'_> {
|
||||
// Safety: `OwnedSocket` and `BorrowedSocket` have the same validity
|
||||
// invariants, and the `BorrowdSocket` is bounded by the lifetime
|
||||
// of `&self`.
|
||||
unsafe { BorrowedSocket::borrow_raw_socket(self.as_raw_socket()) }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user