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

Method set_pos

block-buffer/src/sealed.rs:50–58  ·  view source on GitHub ↗
(buf: &mut Block<N>, _pos: &mut Self::Pos, val: usize)

Source from the content-addressed store, hash-verified

48
49 #[allow(clippy::cast_possible_truncation)]
50 fn set_pos<N: ArraySize>(buf: &mut Block<N>, _pos: &mut Self::Pos, val: usize) {
51 debug_assert!(u8::try_from(val).is_ok());
52 // SAFETY: we write to the last byte of `buf` which is always safe
53 unsafe {
54 let buf_ptr = buf.as_mut_ptr().cast::<u8>();
55 let last_byte_ptr = buf_ptr.add(N::USIZE - 1);
56 ptr::write(last_byte_ptr, val as u8);
57 }
58 }
59
60 #[inline(always)]
61 fn invariant(pos: usize, block_size: usize) -> bool {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected