about summary refs log tree commit diff
path: root/library/std/src/os/unix/net
diff options
context:
space:
mode:
authorJosh Triplett <josh@joshtriplett.org>2024-03-28 14:30:32 +0000
committerJosh Triplett <josh@joshtriplett.org>2024-05-13 15:11:28 +0200
commita5a60d75a87881f79deea115d7cd002ce3373fd5 (patch)
treef00afa73a0aeba422e5c09f21a103ebaa0213d9a /library/std/src/os/unix/net
parent6be7b0c7d2b085474f9f2f9323c2266f4df105d8 (diff)
downloadrust-a5a60d75a87881f79deea115d7cd002ce3373fd5.tar.gz
rust-a5a60d75a87881f79deea115d7cd002ce3373fd5.zip
Add `size_of`, `size_of_val`, `align_of`, and `align_of_val` to the prelude
Many, many projects use `size_of` to get the size of a type. However,
it's also often equally easy to hardcode a size (e.g. `8` instead of
`size_of::<u64>()`). Minimizing friction in the use of `size_of` helps
ensure that people use it and make code more self-documenting.

The name `size_of` is unambiguous: the name alone, without any prefix or
path, is self-explanatory and unmistakeable for any other functionality.
Adding it to the prelude cannot produce any name conflicts, as any local
definition will silently shadow the one from the prelude. Thus, we don't
need to wait for a new edition prelude to add it.

Add `size_of_val`, `align_of`, and `align_of_val` as well, with similar
justification: widely useful, self-explanatory, unmistakeable for
anything else, won't produce conflicts.
Diffstat (limited to 'library/std/src/os/unix/net')
-rw-r--r--library/std/src/os/unix/net/ancillary.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/library/std/src/os/unix/net/ancillary.rs b/library/std/src/os/unix/net/ancillary.rs
index 0597fdcbd72..fe8e2be9372 100644
--- a/library/std/src/os/unix/net/ancillary.rs
+++ b/library/std/src/os/unix/net/ancillary.rs
@@ -3,7 +3,7 @@
 use super::{sockaddr_un, SocketAddr};
 use crate::io::{self, IoSlice, IoSliceMut};
 use crate::marker::PhantomData;
-use crate::mem::{size_of, zeroed};
+use crate::mem::zeroed;
 use crate::os::unix::io::RawFd;
 use crate::path::Path;
 use crate::ptr::{eq, read_unaligned};