diff options
| author | Thalia Archibald <thalia@archibald.dev> | 2025-03-04 20:28:38 -0800 |
|---|---|---|
| committer | Thalia Archibald <thalia@archibald.dev> | 2025-03-06 20:20:38 -0800 |
| commit | 988eb1997014987caad878699ee1e7c000214508 (patch) | |
| tree | 18f3a0bc36f4f660467f921878f917b36f13c8d0 /library/std/src/os/unix/net/ucred.rs | |
| parent | 08db600e8e276b548e986abe7239c2a85d2f425f (diff) | |
| download | rust-988eb1997014987caad878699ee1e7c000214508.tar.gz rust-988eb1997014987caad878699ee1e7c000214508.zip | |
library: Use size_of from the prelude instead of imported
Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the
prelude instead of importing or qualifying them.
These functions were added to all preludes in Rust 1.80.
Diffstat (limited to 'library/std/src/os/unix/net/ucred.rs')
| -rw-r--r-- | library/std/src/os/unix/net/ucred.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/library/std/src/os/unix/net/ucred.rs b/library/std/src/os/unix/net/ucred.rs index e1014a4f296..2dd7d409e48 100644 --- a/library/std/src/os/unix/net/ucred.rs +++ b/library/std/src/os/unix/net/ucred.rs @@ -41,15 +41,15 @@ mod impl_linux { use libc::{SO_PEERCRED, SOL_SOCKET, c_void, getsockopt, socklen_t, ucred}; use super::UCred; + use crate::io; use crate::os::unix::io::AsRawFd; use crate::os::unix::net::UnixStream; - use crate::{io, mem}; pub fn peer_cred(socket: &UnixStream) -> io::Result<UCred> { - let ucred_size = mem::size_of::<ucred>(); + let ucred_size = size_of::<ucred>(); // Trivial sanity checks. - assert!(mem::size_of::<u32>() <= mem::size_of::<usize>()); + assert!(size_of::<u32>() <= size_of::<usize>()); assert!(ucred_size <= u32::MAX as usize); let mut ucred_size = ucred_size as socklen_t; @@ -64,7 +64,7 @@ mod impl_linux { &mut ucred_size, ); - if ret == 0 && ucred_size as usize == mem::size_of::<ucred>() { + if ret == 0 && ucred_size as usize == size_of::<ucred>() { Ok(UCred { uid: ucred.uid, gid: ucred.gid, pid: Some(ucred.pid) }) } else { Err(io::Error::last_os_error()) @@ -101,9 +101,9 @@ mod impl_apple { use libc::{LOCAL_PEERPID, SOL_LOCAL, c_void, getpeereid, getsockopt, pid_t, socklen_t}; use super::UCred; + use crate::io; use crate::os::unix::io::AsRawFd; use crate::os::unix::net::UnixStream; - use crate::{io, mem}; pub fn peer_cred(socket: &UnixStream) -> io::Result<UCred> { let mut cred = UCred { uid: 1, gid: 1, pid: None }; @@ -115,7 +115,7 @@ mod impl_apple { } let mut pid: pid_t = 1; - let mut pid_size = mem::size_of::<pid_t>() as socklen_t; + let mut pid_size = size_of::<pid_t>() as socklen_t; let ret = getsockopt( socket.as_raw_fd(), @@ -125,7 +125,7 @@ mod impl_apple { &mut pid_size, ); - if ret == 0 && pid_size as usize == mem::size_of::<pid_t>() { + if ret == 0 && pid_size as usize == size_of::<pid_t>() { cred.pid = Some(pid); Ok(cred) } else { |
