MCPcopy Create free account
hub / github.com/RustCrypto/utils / word_to_slice

Function word_to_slice

cmov/src/slice.rs:391–405  ·  view source on GitHub ↗
(word: Word, out: &mut [T])

Source from the content-addressed store, hash-verified

389#[inline]
390#[allow(clippy::arithmetic_side_effects)]
391fn word_to_slice<T>(word: Word, out: &mut [T])
392where
393 T: BitOrAssign + Copy + From<u8> + Shl<usize, Output = T>,
394{
395 debug_assert!(size_of::<T>() > 0, "can't be used with ZSTs");
396 debug_assert!(out.len() <= WORD_SIZE, "slice too large");
397
398 let bytes = word.to_le_bytes();
399 for (o, chunk) in out.iter_mut().zip(bytes.chunks(size_of::<T>())) {
400 *o = T::from(0u8);
401 for (i, &byte) in chunk.iter().enumerate() {
402 *o |= T::from(byte) << (i * 8);
403 }
404 }
405}
406
407//
408// Vendored `core` functions to allow a 1.85 MSRV

Callers 1

cmovnz_remainderFunction · 0.85

Calls 1

zipMethod · 0.80

Tested by

no test coverage detected