Function bitwise::word::reverse_byte_groups
[−]
[src]
pub fn reverse_byte_groups<T: Word, U: UnsignedWord>(x: T,
group_byte_size: U,
no_subwords: U)
-> T
Reverses groups of bytes within each subword of x
group_byte_size
- The size (in bytes) of the groups of bytes to be reversed.no_subwords
- The number of subwords inx
.
The word x
is divided into no_subwords
. The byte groups of size
group_byte_size
are reversed within each subword. Bits within a byte group
are not reversed.
The size in bits of a subword is thus x::bit_size() / no_subword
. When
no_suboword == 1
the subword equals the original word. When
group_byte_size == 1
bytes are reversed within a subword.
Examples
use bitwise::word::*; // Single bytes: assert_eq!(0b0101_1101_1010_0101_u16.reverse_byte_groups(1u32, 1u32), 0b1010_0101_0101_1101u16); // Single bytes within two half-words: assert_eq!(reverse_byte_groups(0b0101_1101_1010_0101_0101_1101_1010_0101u32, 1u32, 2u32), 0b1010_0101_0101_1101_1010_0101_0101_1101u32);