injectorpp 0.5.1

Injectorpp is a powerful tool designed to facilitate the writing of unit tests without the need to introduce traits solely for testing purposes. It streamlines the testing process by providing a seamless and efficient way to abstract dependencies, ensuring that your code remains clean and maintainable.
Documentation
#![cfg(target_arch = "aarch64")]

/// Convert a u64 value into a [bool; 64] array of bits.
/// Bit 0 is the least-significant bit.
pub(crate) fn u64_to_bits(n: u64) -> [bool; 64] {
    let mut bits = [false; 64];
    for (i, bit) in bits.iter_mut().enumerate() {
        *bit = ((n >> i) & 1) != 0;
    }
    bits
}

/// Converts an 8-bit number into an array of N booleans representing its bits.
/// The least-significant bit is at index 0.
pub(crate) fn u8_to_bits<const N: usize>(n: u8) -> [bool; N] {
    let mut bits = [false; N];
    for (i, bit) in bits.iter_mut().enumerate() {
        *bit = ((n >> i) & 1) != 0;
    }
    bits
}

pub(crate) fn bool_array_to_u32(bits: [bool; 32]) -> u32 {
    bits.iter()
        .enumerate()
        .fold(0, |acc, (i, &bit)| if bit { acc | (1 << i) } else { acc })
}