diff options
| author | LinkTed <LinkTed@users.noreply.github.com> | 2020-08-25 18:14:10 +0200 |
|---|---|---|
| committer | LinkTed <LinkTed@users.noreply.github.com> | 2020-10-10 15:19:11 +0200 |
| commit | e1084052a7f6d65a5c5e9656ba507ba42c4caacb (patch) | |
| tree | 9308597d4f866595c5ada6bcae1a618adf5f6626 /library/std/src/sys | |
| parent | 8784ffbb4e45c6081369805fccd34b77f3ef8ec1 (diff) | |
| download | rust-e1084052a7f6d65a5c5e9656ba507ba42c4caacb.tar.gz rust-e1084052a7f6d65a5c5e9656ba507ba42c4caacb.zip | |
Replace `TryFrom` of `AncillaryData` with a private method.
Diffstat (limited to 'library/std/src/sys')
| -rw-r--r-- | library/std/src/sys/unix/ext/net/ancillary.rs | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/library/std/src/sys/unix/ext/net/ancillary.rs b/library/std/src/sys/unix/ext/net/ancillary.rs index 039cdd8ff91..142526f3a41 100644 --- a/library/std/src/sys/unix/ext/net/ancillary.rs +++ b/library/std/src/sys/unix/ext/net/ancillary.rs @@ -349,29 +349,24 @@ impl<'a> AncillaryData<'a> { let scm_credentials = ScmCredentials(ancillary_data_iter); AncillaryData::ScmCredentials(scm_credentials) } -} -#[cfg(any( - target_os = "haiku", - target_os = "solaris", - target_os = "illumos", - target_os = "macos", - target_os = "ios", - target_os = "freebsd", - target_os = "dragonfly", - target_os = "openbsd", - target_os = "netbsd", - target_os = "linux", - target_os = "android", - target_os = "emscripten", - target_os = "fuchsia", - target_env = "uclibc", -))] -#[unstable(feature = "unix_socket_ancillary_data", issue = "none")] -impl<'a> TryFrom<&'a libc::cmsghdr> for AncillaryData<'a> { - type Error = AncillaryError; - - fn try_from(cmsg: &'a libc::cmsghdr) -> Result<Self, Self::Error> { + #[cfg(any( + target_os = "haiku", + target_os = "solaris", + target_os = "illumos", + target_os = "macos", + target_os = "ios", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "openbsd", + target_os = "netbsd", + target_os = "linux", + target_os = "android", + target_os = "emscripten", + target_os = "fuchsia", + target_env = "uclibc", + ))] + fn try_from_cmsghdr(cmsg: &'a libc::cmsghdr) -> Result<Self, AncillaryError> { unsafe { let cmsg_len_zero = libc::CMSG_LEN(0) as usize; let data_len = (*cmsg).cmsg_len - cmsg_len_zero; @@ -472,7 +467,7 @@ impl<'a> Iterator for Messages<'a> { let cmsg = cmsg.as_ref()?; self.current = Some(cmsg); - let ancillary_result = AncillaryData::try_from(cmsg); + let ancillary_result = AncillaryData::try_from_cmsghdr(cmsg); Some(ancillary_result) } } |
