about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
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
commit3927f4adfa7df520703443e622a395622e68377b (patch)
tree49fd5231b45651fda6cb1882195d63c6573d0c41 /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
parent4fa3e88811c088d8d3da7e99dc1602f2b48156f9 (diff)
downloadrust-3927f4adfa7df520703443e622a395622e68377b.tar.gz
rust-3927f4adfa7df520703443e622a395622e68377b.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 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions