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.
This commit is contained in:
parent
6be7b0c7d2
commit
a5a60d75a8
18 changed files with 22 additions and 23 deletions
|
@ -104,7 +104,6 @@
|
|||
|
||||
use super::{Custom, ErrorData, ErrorKind, RawOsError, SimpleMessage};
|
||||
use core::marker::PhantomData;
|
||||
use core::mem::{align_of, size_of};
|
||||
use core::ptr::{self, NonNull};
|
||||
|
||||
// The 2 least-significant bits are used as tag.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue