pub(crate) macro unsafe_impl_fd_asrefs($($t:ty),*$(,)?) {
...
}Available on Hermit or Motor OS or Trusty or Unix or WASI only.
Expand description
Implements AsRef<$t> conversions from BorrowedFd to the specified types.
§Safety
It must be sound to transmute &BorrowedFd to &$t.
This typically implies that:
- $t must be a wrapper with
BorrowedFd,OwnedFdorRawFdbeing the single non-ZST-field. Nominally it also requires repr(transparent), but std can cheat because we can stay in sync with rustc’s layout implementation details. &$tmust not have any methods that would allow closing the file descriptor.&$timpls must tolerate instances being created from any kind of file-descriptor without going through some dedicated constructor function, akin toFrom<OwnedFd>being a noop conversion.