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 {
|
impl AsFd for OwnedFd {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn as_fd(&self) -> BorrowedFd<'_> {
|
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()) }
|
unsafe { BorrowedFd::borrow_raw_fd(self.as_raw_fd()) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -177,6 +177,9 @@ fn as_fd(&self) -> BorrowedFd<'_> {
|
|||||||
impl AsFd for OwnedFd {
|
impl AsFd for OwnedFd {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn as_fd(&self) -> BorrowedFd<'_> {
|
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()) }
|
unsafe { BorrowedFd::borrow_raw_fd(self.as_raw_fd()) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -282,6 +282,9 @@ fn as_handle(&self) -> BorrowedHandle<'_> {
|
|||||||
impl AsHandle for OwnedHandle {
|
impl AsHandle for OwnedHandle {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn as_handle(&self) -> BorrowedHandle<'_> {
|
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()) }
|
unsafe { BorrowedHandle::borrow_raw_handle(self.as_raw_handle()) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,6 +145,9 @@ fn as_socket(&self) -> BorrowedSocket<'_> {
|
|||||||
impl AsSocket for OwnedSocket {
|
impl AsSocket for OwnedSocket {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn as_socket(&self) -> BorrowedSocket<'_> {
|
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()) }
|
unsafe { BorrowedSocket::borrow_raw_socket(self.as_raw_socket()) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user