diff options
| author | LeSeulArtichaut <leseulartichaut@gmail.com> | 2020-04-23 18:32:41 +0200 |
|---|---|---|
| committer | LeSeulArtichaut <leseulartichaut@gmail.com> | 2020-04-23 18:32:41 +0200 |
| commit | 3029e9e9e476337b9e2c71de669e87839bb19ed5 (patch) | |
| tree | 1a820c36849f60bd92d5bbf35c8e021e7ded1c3e /src/libcore/hash | |
| parent | b84f9813618e6d8de68e91022e942562940a83cc (diff) | |
| download | rust-3029e9e9e476337b9e2c71de669e87839bb19ed5.tar.gz rust-3029e9e9e476337b9e2c71de669e87839bb19ed5.zip | |
Add note about padding
Co-authored-by: Mark-Simulacrum <mark.simulacrum@gmail.com>
Diffstat (limited to 'src/libcore/hash')
| -rw-r--r-- | src/libcore/hash/mod.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/libcore/hash/mod.rs b/src/libcore/hash/mod.rs index 14ca0826733..4f66b00b279 100644 --- a/src/libcore/hash/mod.rs +++ b/src/libcore/hash/mod.rs @@ -570,8 +570,9 @@ mod impls { fn hash_slice<H: Hasher>(data: &[$ty], state: &mut H) { let newlen = data.len() * mem::size_of::<$ty>(); let ptr = data.as_ptr() as *const u8; - // SAFETY: `ptr` is valid and aligned, the new slice only spans - // across `data` and is never mutated, and its total size is the + // SAFETY: `ptr` is valid and aligned, as this macro is only used + // for numeric primitives which have no padding. The new slice only + // spans across `data` and is never mutated, and its total size is the // same as the original `data` so it can't be over `isize::MAX`. state.write(unsafe { slice::from_raw_parts(ptr, newlen) }) } |
