Skip to main content

limb_slice_as_bytes_mut

Function limb_slice_as_bytes_mut 

Source
pub fn limb_slice_as_bytes_mut(limbs: &mut [LimbType]) -> &mut [u8] ⓘ
Expand description

View a mutable LimbType slice as a mutable byte slice.

Returns a mutable byte slice covering the same memory as limbs, of length limbs.len() times the LimbType size in bytes. The bytes are in memory order, i.e. each limb’s bytes appear in the host’s native endianess.

This is useful for filling a LimbType slice, e.g. one to be wrapped in a MpMutNativeEndianUIntLimbsSlice, from a source producing bytes, most notably a random number generator. As all bytes produced by a random number generator are equally random, the host’s endianess doesn’t matter in this case. As any bit pattern is a valid LimbType value, any byte values may be written.

§Arguments

  • limbs - The LimbType slice to view as bytes.