diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-03-18 12:04:24 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-18 12:04:24 +0100 |
| commit | 0aa0043141004d9a3cfc94b46c78eaa789158b80 (patch) | |
| tree | 385cc4425265e21a6b7746c5bee6636d4ac906f9 /library/core/src | |
| parent | e81a07268b233ec6940b65444a6c32ceef28ce10 (diff) | |
| parent | 35088797aec481a9549d5d495b27ce9f1e3a39dd (diff) | |
| download | rust-0aa0043141004d9a3cfc94b46c78eaa789158b80.tar.gz rust-0aa0043141004d9a3cfc94b46c78eaa789158b80.zip | |
Rollup merge of #109287 - scottmcm:hash-slice-size-of-val, r=oli-obk
Use `size_of_val` instead of manual calculation Very minor thing that I happened to notice in passing, but it's both shorter and [means it gets `mul nsw`](https://rust.godbolt.org/z/Y9KxYETv5), so why not.
Diffstat (limited to 'library/core/src')
| -rw-r--r-- | library/core/src/hash/mod.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/library/core/src/hash/mod.rs b/library/core/src/hash/mod.rs index 3bdde0993b9..4e7bae7bcb0 100644 --- a/library/core/src/hash/mod.rs +++ b/library/core/src/hash/mod.rs @@ -834,7 +834,7 @@ mod impls { #[inline] fn hash_slice<H: ~const Hasher>(data: &[$ty], state: &mut H) { - let newlen = data.len() * mem::size_of::<$ty>(); + let newlen = mem::size_of_val(data); let ptr = data.as_ptr() as *const u8; // SAFETY: `ptr` is valid and aligned, as this macro is only used // for numeric primitives which have no padding. The new slice only |
