rust/library/core/src/ptr
Jubilee 9ccc7b78ec
Rollup merge of #123168 - joshtriplett:size-of-prelude, r=Amanieu
Add `size_of` and `size_of_val` and `align_of` and `align_of_val` to the prelude

(Note: need to update the PR to add `align_of` and `align_of_val`, and remove the second commit with the myriad changes to appease the lint.)

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.
2024-06-05 01:14:29 -07:00
..
alignment.rs Import the 2021 prelude in the core crate 2024-03-25 13:12:06 -07:00
const_ptr.rs Add assert_unsafe_precondition to unchecked_{add,sub,neg,mul,shl,shr} methods 2024-05-23 21:02:31 -04:00
metadata.rs [ACP 362] genericize ptr::from_raw_parts 2024-05-29 09:34:16 -07:00
mod.rs Rollup merge of #123168 - joshtriplett:size-of-prelude, r=Amanieu 2024-06-05 01:14:29 -07:00
mut_ptr.rs Add assert_unsafe_precondition to unchecked_{add,sub,neg,mul,shl,shr} methods 2024-05-23 21:02:31 -04:00
non_null.rs Add assert_unsafe_precondition to unchecked_{add,sub,neg,mul,shl,shr} methods 2024-05-23 21:02:31 -04:00
unique.rs Add and use Unique::as_non_null_ptr 2024-02-08 19:56:30 -05:00