Skip to content

Commit d2678ec

Browse files
committed
make MsgHdr and MsgHdrMut repr(transparent) to allow legally obtaining libc::msghdr from those types
1 parent feac83a commit d2678ec

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# Unreleased
2+
3+
## Non-breaking changes
4+
5+
* Added `repr(transparent)` attribute to `MsgHdr` and `MsgHdrMut` to allow legally transmuting those types into corresponding libc equivalent
6+
(https://github.com/rust-lang/socket2/pull/635).
7+
18
# 0.6.1
29

310
## Added

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,7 @@ impl TcpKeepalive {
562562
/// This wraps `msghdr` on Unix and `WSAMSG` on Windows. Also see [`MsgHdrMut`]
563563
/// for the variant used by `recvmsg(2)`.
564564
#[cfg(not(target_os = "redox"))]
565+
#[repr(transparent)]
565566
pub struct MsgHdr<'addr, 'bufs, 'control> {
566567
inner: sys::msghdr,
567568
#[allow(clippy::type_complexity)]
@@ -630,6 +631,7 @@ impl<'name, 'bufs, 'control> fmt::Debug for MsgHdr<'name, 'bufs, 'control> {
630631
/// This wraps `msghdr` on Unix and `WSAMSG` on Windows. Also see [`MsgHdr`] for
631632
/// the variant used by `sendmsg(2)`.
632633
#[cfg(not(target_os = "redox"))]
634+
#[repr(transparent)]
633635
pub struct MsgHdrMut<'addr, 'bufs, 'control> {
634636
inner: sys::msghdr,
635637
#[allow(clippy::type_complexity)]

0 commit comments

Comments
 (0)